Update width and height of rectangle dynamically

725 views Asked by At

I am trying to add rectangle to parent rect on clicking submit. I want the height of parent rect increase on adding new rectangle to parent so that it looks like child element resides with in parent like this:

$('.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]);
});

I tried with element.set and element.attr and element.prop methods which didn't work. How do I achieve this?

1

There are 1 answers

1
kittu On BEST ANSWER

Fixed it by using resize() method of jointjs.