Reputation: 81
I am trying to set custom attribute value through a form. But if I click the element again it shows the properties previously assigned rather than showing the one.
I want to input SiteStation variable's value from user and assign it to that particular element. For the time my element is there on the graph it should have that value attatched it.
http://jsfiddle.net/avinash2618/6umUH/157/
cell.set('attributes/stationName',stationName);
Upvotes: 1
Views: 2044
Reputation: 51
Vinay's answer is correct. However, to avoid collisions with future JointJS standard attributes, wrapping your custom attributes in a "data" custom property is advised. Here's an example using an element:
element.prop("data/stationName/text", stationName)
This way, you can use any property name (e.g., label, id, text...) without worrying about collisions with existing and future JointJS property names.
For more, see https://resources.jointjs.com/tutorial/custom-attributes
Upvotes: 0
Reputation: 773
you can try setting the text property of the custom attribute as below
cell.attr('stationName/text', stationName);
or if it is a view
cellView.model.attr('stationName/text', stationName);
Upvotes: 2