我用JointJS库创建了一个自定义元素.该对象有两个嵌套的矩形和两个相关的文本.
我想改变他在模型中的属性...我只通过JQUERY改变他的属性和css,通过它的ID.
我想更改模型中的attrs,然后更新节点以显示他的新外观.
对不起,如果我不能很好地解释它,我留下一个jsFiddle - >
如果您需要其他信息,请询问.
谢谢.
这是定义我的自定义对象的类,在jsfiddle上你可以举个例子:
MyRect = joint.shapes.basic.Generic.extend({
markup: [
'<g class="rotatable">',
'<g class="scalable">',
'<rect class="firstRect"/><rect class="secondRect"/>',
'</g>',
'<text class="textFirstRect"/><text class="textSecondRect"/>',
'</g>'].join(''),
defaults: joint.util.deepSupplement({
type: 'basic.MyRect',
attrs: {
'.firstRect': {
'stroke': '#0A1317',
'stroke-width': 1,
'fill': '#DBF024',
'width': 100,
'height': 30,
},
'.secondRect': {
'stroke': '#0A1317',
'stroke-width': 1,
'fill': '#DBF024',
'width': 100,
'height': 30,
},
'.textFirstRect': {
'ref': '.firstRect',
'ref-x': .5,
'ref-y': .5,
'y-alignment': 'middle',
'x-alignment': 'middle',
'fill': '#333',
'font-size': 12,
'font-family': 'Calibri,Arial',
},
'.textSecondRect': { …Run Code Online (Sandbox Code Playgroud)