单击事件在关节js中无法正常工作

时间:2016-05-11 14:58:54

标签: jquery jointjs

我用自定义类得到了这个联合js rect:

var rectdetail= new joint.shapes.basic.Rect({
markup: '<g class="rotatable"><g class="scalable"><rect class="inner"/></g><text/></g>',
    position: { x: 450, y: y_value +10},
    size: { width: 130, height: 35 },
    attrs: { 
        ".inner": { fill: '#333','stroke-width': 0  },
        text: {
            text: 'View detail',
            fill: 'white'
        }
    }
});

我添加了一个点击事件,因此它打开了一个模态:

$(document).on('click', '.inner', function () {
    var id = $(this).attr('id');
    //alert(id);
    $('#myModal1').modal('show');
});

事情是,我的点击事件仅在我点击文字外面时才有效。查看详情&#39;在矩形内部,我该如何解决这个问题呢?

提前致谢!

1 个答案:

答案 0 :(得分:0)

您可以使用此处提到的jointjs特定事件处理程序:

How to add an onclick event to a joint.js element?

paper.on('cell:pointerclick', 
    function(cellView, evt, x, y) {
       var id = cellView.model.id;
       $('#myModal1').modal('show');
    }
);