Monday, 15 February 2010

json - How to set source and target in JSPlumb dynamically -



json - How to set source and target in JSPlumb dynamically -

i using jsplumb go show pictorial view of devices connected switch. next below approach, please comment in case if it's not per standard.

creating map of devices connected in network, , dynamically create devices on screen using innerhtml. create mapping json contain devices connected device. i iterate json using javascript , create source , target devices on screen.

problem: when iterate through json, source , target not able set in below code.

var result = json.parse(devicepaths); (var in result) { var _source = new string(result[i]["source"]); var _target = new string(result[i]["target"]); var _endpoint = new string(result[i]["endpoint"]); console.log('_source ' + _source); //this gives me proper value console.log('_target ' + _target); //this gives me proper value console.log('_endpoint ' + _endpoint); instance = jsplumb.getinstance({ paintstyle : { linewidth : 1, strokestyle : "#567567", outlinecolor : "black", outlinewidth : 1 } }); mutual = { anchors : [ "bottomcenter", "bottomcenter" ], endpoints : [ "dot", "blank" ] } instance.connect({ source : _source, target : _target, detachable : false, endpoint : _endpoint }, common); instance.draggable(_source); } });

same works if hardcode source , target values source : rx_1 , target masterswitch.

json jsplumb

No comments:

Post a Comment