动态更新矩形的宽度和高度

时间:2015-09-14 13:27:49

标签: javascript backbone.js svg jointjs

我正在尝试在单击提交时向父rect添加矩形。我想在父级添加新矩形时增加父级矩的高度,以便看起来子元素在父级中驻留如下:

$('.modeler_add_button').click(function (e)
{
    var parentValues = parent1.getBBox();
    var parentHeight = parentValues.height;
//    parent1.attr('height', parentHeight+25);
//    parent1.prop('height', parentHeight+25);
    parent1.set('height', parentHeight + 25);

    var newRect = new joint.shapes.tm.Actor({
        isInteractive: false,
        position: {x: pos.x + 1, y: pos.y + 25},
        size: {width: 120, height: 25},
        attrs: {
            text: {text: 'res', fill: 'black', 'font-weight': 'bold', 'font-size': 12},
            rect: {
                fill: '#F1F1F1', rx: 7, ry: 15, opacity: .80, 'stroke-width': 0, stroke: '#fff'
            }
        }
    });
    parent1.embed(newRect);
    graph.addCells([newRect]);
});

我尝试使用element.setelement.attr以及element.prop方法无效。我如何实现这一目标?

1 个答案:

答案 0 :(得分:0)

使用{j}的resize()方法修正了它。

相关问题