B4J Question [WebApp] How to use WS.EvalWithResult()?

Kiffi

Well-Known Member
Licensed User
Longtime User
Hello,

i have add dynatree to my index.html and now i want to get the active treenode.

in JavaScript, the following snippet works for me:

Code:
$( "#myButton" ).on( "click", function() {
    var tree = $("#dynatree").dynatree('getTree');
    var activeNode = tree.getActiveNode();
    alert(activeNode);
});

now i want to do the same in a B4J-WebApp (Websocket).
I get the click-event and execute the following EvalWithResult():

Code:
Dim Tree As Future = _
  WS.EvalWithResult("$(arguments[0]).dynatree('getTree')", _
  Array As Object(DynaTree.Id))

Log("Tree: " & Tree.Value)

(DynaTree.Id contains the correct value #dynatree)

... but unfortunately Tree.Value is always null.

My Question: is my EvalWithResult()-Call correct? I didn't find an example how to use it.

Thanks in advance & Greetings ... Peter
 
Hello Erel,

whow! Faster than lightning! :)

already tried. With 'return $(...' i get a uncaught TypeError (see attachment).

Thanks & Greetings ... Peter
 

Attachments

  • 2014-04-29_152449.png
    2014-04-29_152449.png
    6 KB · Views: 680
Upvote 0
You are trying to return an object that cannot be sent as is. You should instead return only the id or some other property.
ah, ok, i see.

Code:
Dim ActiveNodeTitle As Future = _
WS.EvalWithResult("return $(arguments[0]).dynatree('getActiveNode').data.title", _
Array As Object(DynaTree.Id))
   
Log("ActiveNode: " & ActiveNodeTitle.Value)

Now it works like a charm.
allrightb4rn0.gif


Thanks a lot & Greetings ... Peter
 
Upvote 0
Back
Top