单击事件在联合 js 中无法正常工作

Click event not working properly in joint js

我得到了这个带有自定义的联合 js 矩形 class :

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');
});

问题是,只有当我在矩形内的文本 'View detail' 之外单击时,我的点击事件才有效,我该如何解决这个问题?

提前致谢!

您可以使用此处提到的 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');
    }
);