Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 是否更改JointJs纸张的交互属性?_Javascript_Backbone.js_Jointjs - Fatal编程技术网

Javascript 是否更改JointJs纸张的交互属性?

Javascript 是否更改JointJs纸张的交互属性?,javascript,backbone.js,jointjs,Javascript,Backbone.js,Jointjs,最近我需要制作一个JointJs图的交互模式。众所周知,纸张对象的创建过程如下所示: paper = new joint.dia.Paper({ el: $(#myDiagram), width: this.props.width, height: this.props.height, model: this.state.graph, gridSize: 1, interactive: false });

最近我需要制作一个JointJs图的交互模式。众所周知,纸张对象的创建过程如下所示:

    paper = new joint.dia.Paper({
      el: $(#myDiagram),
      width: this.props.width,
      height: this.props.height,
      model: this.state.graph,
      gridSize: 1,
      interactive: false
    });

您可以使用所需的选项创建新图纸。在这种情况下,交互(“交互”标志)设置为false。不幸的是,纸张对象上没有get、attrs和set方法。我想创建一个按钮来更改交互标志。它的位置在图纸内的“选项”对象中。手动访问会更改值,但这根本不反映纸张。是在每次更改交互时重新初始化它的唯一解决方案吗?事先谢谢。

您已经试过打电话了吗

paper.render()

更改值后?

我对此问题的修复方法如下:

_.forEach(this.graph.getLinks(), function (link:joint.dia.Link) {
    self.paper.findViewByModel(link).options.interactive = {
        vertexAdd: true,
        vertexMove: true,
        vertexRemove: true,
        arrowheadMove: false
    }
});
(我使用了大卫·杜尔曼对这个问题的回答:)


这使我可以更改所有链接的交互性(特别是更改顶点),而无需再次进行纸张初始化。

这已经改变,并且变得更好。我现在使用的是jointjs 1.0.3,这对我来说很有用:

  edit() {
    const self = this
    this.graph.getCells().forEach(function (cell) {
      const c = cell.findView(self.paper)
      c.setInteractivity(true)
    })
  }

毕竟,它是一个主干模型/视图。所以这可能行得通。我目前的情况也一样。更改值后调用paper.render()对我无效。我找到了一个解决方案并将其作为答案发布。