Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
sanj1504
Posts: 104
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none
Accepted Solution

JS function name in a variable. How to call it ?

Hi,

    I have a javascript function name in a variable in qml. I need to call that function in qml. How to call it.

I have passed my function name from c++ (for example-- fnCallLog(param) ) in qml using signal and slot. Now i need to call js function fnCallLog(param) in qml . 

In javascript i can use window function, but here it is not accessible. How to call it here.

 

Regards,

Sanjeev

      

      

Please use plain text.
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)
My Carrier: Mobile Vikings

Re: JS function name in a variable. How to call it ?

Not fully sure what you're after but you can assign stuff to the Qt object in Javascript.

 

Qt.fixThatSink = function(brokenSink){ ... }

 

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
Developer
sanj1504
Posts: 104
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: JS function name in a variable. How to call it ?

from c++ i will receive a javascript function name using Q_INVOKABLE function call. now i need to call that javascript function which is on the html page(contain js function) loaded on the screen through webview .
Please use plain text.
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)
My Carrier: Mobile Vikings

Re: JS function name in a variable. How to call it ?

Oops, misunderstood you there. Well you can try the evaluateJavascript(QString) method on your WebView. You can get the result using the javascriptResult(id, QVariant) signal on the WebView.

 

This BlackBerry Builder session may be helpfull.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
Developer
sanj1504
Posts: 104
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: JS function name in a variable. How to call it ?

evaluateJavaScript is returning me value as "1 " but my function is not being called.
Please use plain text.
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)
My Carrier: Mobile Vikings

Re: JS function name in a variable. How to call it ?

Well, evaluateJavascript returns the id that will be used by the signal. This way you can know what output the signal is returning.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
Developer
sanj1504
Posts: 104
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: JS function name in a variable. How to call it ?

it was working . i didnt notice what i was returning  :Clap:

Please use plain text.