Search code examples
jqueryjsonmodel-view-controllerdynatree

How to get selectable dynatree output as JSON?


I am have created a selectable JQuery Dynatree object, and now what I want are two things:

  1. pass the Dynatree selection result into JSON and pass to another tree as a preview.
  2. post the JSON format data from the form to call related web services.

Any advice will be appreciated. thanks.


Solution

  • You can easily see from the documentation (and in the samples page) that you can get all selected nodes by using getSelectedNodes as:

    $("#tree").dynatree("getSelectedNodes")
    

    This will get you an array of all selected nodes, which you can pass to your JSON object without tampering with this, as JSON access arrays.

    To use a preview, you can check the Drag'n'drop 3 sample.