@vihag wrote:
- I am trying to create a palette based canvas.
- I have created my own node definitions, each node has a a data property 'configurations' which is an array of fixed schema objects('name','value','defaultValue','description')
- When I drop two of these nodes onto the canvas, i want to update the configurations of the two nodes separately
- when i am updating the 2nd node with the configurations, the first node also assumes the same values, which is undesirable.
How do i make sure that the two nodes have separate configurations ?
Code snippet for adding palette nodes ->
` jQuery.each(activeGenomes, function(key, value) {genomePalette.model.addNodeData({ key: value.id, genome: value.name, displayname: value.name, inputSchema: value.inputSchema, outputSchema: value.outputSchema, configuration: value.configuration, jarName: value.jarName, className: value.className, fig: "hexagon", type: "genome" }); });`Code Snippet for updating values of configs based on user input ->
`function updateNodeConfigurations() {var clickedNodeKey = subjectBeingConfigured.part.data.key; genomeCanvas.startTransaction("savenewconfig"); var clickedNode; jQuery.each(genomeCanvas.model.nodeDataArray, function(key, node) { console.log("comparing "+node.key+" with "+clickedNodeKey); if (node.key === clickedNodeKey){ clickedNode = node; return false; } }); console.log("Subject part data : "+subjectBeingConfigured.part.data.configuration); console.log("Updating configurations for : " + clickedNode.data); jQuery.each(clickedNode.configuration, function(key, config) { //we are looping over each configuration of the clicked node configurationId = '#' + clickedNode.key + '_' + config.name; var valueForConfiguration = jQuery(configurationId).val(); console.log("config old value : " + config.name + " : " + config.value); console.log("config new value : " + config.name + " : " + valueForConfiguration); config.value = valueForConfiguration; //genomeCanvas.model.setDataProperty(clickedNode,"configuration", valueForConfiguration) return true; }); console.log() genomeCanvas.commitTransaction("savenewconfig");}`
Posts: 2
Participants: 2
