I want when writing something on the inspector displayName edit text to pass it to the inbox name of every element.
My javascript code is the following:
var count = 0;
//Code to edit element inboxName with value given from displayName field
cell.on('change:wi_displayName', function(cell, change, opt) {
if(count == 0){
//Do nothing the 1st time
}
else {
var inboxName = cell.get('wi_displayName');
cell.set( cell.attr('text/text'), inboxName);
}
count++;
})
//End of code to edit element inboxName with value given from displayName field
but the problem is in the final line:
cell.set( cell.attr('text/text'), inboxName);
How should I set the value?
My stencil json for this element is :
new joint.shapes.basic.Circle({
size: { width: 5, height: 3 },
attrs: {
circle: { width: 50, height: 30, fill: '#000000' },
text: { text: 'START', fill: '#ffffff', 'font-size': 10, stroke: '#000000', 'stroke-width': 0 }
}
})
Thank you
You can set the text attribute on your
basic.Circle
element withcell.attr('text/text', inboxName)
. Theattr()
method takes a path as the first argument which is the path to the attribute in yourattrs
object. Note thatcell.attr('text/text', 'MY VALUE')
is equivalent tocell.prop('attrs/text/text', 'MY VALUE')
.cell.set()
can only be used to set top level properties, so you would have to docell.set('attrs', { text: { text: 'MY VALUE' } })
but that would override other attributes (likecircle
in your case).