Search code examples
vue.jsjointjs

How can i use the method like "paper.on('cell:pointerdblclick', function (cellView){})" in a vue file?


I want to use jointjs to achieve a demand, like this: paper.on('cell:pointerdblclick', function(cellView) {}). In vue, what should i do?

ReferenceError: cellView is not defined

<script>
    export default {
    mounted(){},
    methods: {
       registerDoubleClickEvent() 
          {this.paper.on('cell:pointerdblclick', 
           this.connectTwoObject(cellView))},
       connectTwoObject(cellView){alert('1234');},
     }}
</script>

Thanks in advance!


Solution

  • As i understood from the question, you want to pass the first argument of callback to your method. Seems like your syntax is wrong. You are just calling your method with an undefined variable. To access this variable try the code bellow (arrow function is used to save the context). Also, I believe you have connectTwoObject method defined in your methods.

    export default {
      mounted() {},
      methods: {
        registerDoubleClickEvent() {
          this.paper.on('cell:pointerdblclick', cellView =>
            this.connectTwoObject(cellView),
          )
        },
      },
    }