JavaScript jointjs element mouse click event

I'm using jointjs to draw graphs.

I'm wondering how to listen to the mouse click event on an element? I found on http://www.jointjs.com/api#joint.dia.Element, there is only change:position option but no onclick option lol.

There's only cell:pointerclick option on the whole paper instead of the single element.

How can I achieve only listen to mouse click element on the single element? (Say I want to resize the paper after the click) Thanks!

Answer:1

A way to do that it's using classes and javascript events, look:

First, you assign a class to the joint js element via markup , for example a class called 'myclass' in this case:

var rect1 = new joint.shapes.basic.Rect({
markup: '<g class="rotatable"><g class="scalable"><image id="myrect1"  class="myclass"/></g><text/></g>',
    size: { width: 30, height: 73.2 },
    attrs: { 
        rect: { fill: bgcolor1,'stroke-width': 0 },

    }
});

Then, you capture the click event on that class objects via javascript, not in the canvas but in the document :

$(document).on('click', '.myclass', function () {
        //alert('yayy!');
});

Hope it helps !

Answer:2

You can use the pointerclick event to capture the click events on elements. The view is passed as a parameter to the function and you can obtain the model of the view through cellView.model

paper.on('cell:pointerclick', function (cellView) {
   // your logic goes here
);
Answer:3

I have 100 tables on this page and each has a checkbox. My goal is to download the contents of each table that has the corresponding checkbox checked to one cvs file. Here is the code for the table. ...

I have 100 tables on this page and each has a checkbox. My goal is to download the contents of each table that has the corresponding checkbox checked to one cvs file. Here is the code for the table. ...

I've been having trouble trying to apply different JavaScript string manipulation solutions to my specific problem: string str = ":2 E/4 :2 G/4 |:2 G/4 :2 F/4" From the end of the string, I want to ...

I've been having trouble trying to apply different JavaScript string manipulation solutions to my specific problem: string str = ":2 E/4 :2 G/4 |:2 G/4 :2 F/4" From the end of the string, I want to ...

  1. string manipulation with operators javascript
  2. string manipulation with python
  3. string manipulation with r
  4. string manipulation with javascript
  5. string manipulation with powershell
  6. string manipulation with stringr cheat sheet
  7. string manipulation with bash
  8. string manipulation with php
  9. string manipulation with awk
  10. string manipulation with java
  11. string manipulation with linq
  12. string manipulation with regex
  13. string manipulation with jquery
  14. string manipulation with examples
  15. string manipulation with vba
  16. string manipulation with arduino
  17. string manipulation with ruby
  18. string manipulation in c
  19. string manipulation in uipath
  20. string manipulation in excel

Say we have an input field: <input type="text" ref="inputBrand" onChange={this.updateState} /> When the updateState function is called, is there a way to know which element it was called from ...

Say we have an input field: <input type="text" ref="inputBrand" onChange={this.updateState} /> When the updateState function is called, is there a way to know which element it was called from ...

  1. react detect element resize
  2. react detect element in viewport
  3. react detect element scroll
  4. react detect element size change
  5. react detect element in view
  6. react detect element visible
  7. react detect element position change
  8. react detect element
  9. react detect div resize
  10. react detect div height change
  11. react detect if element is in viewport
  12. react detect if element is visible
  13. react detect if element is in view
  14. react detect click outside element

so I have an array in which I store values in pairs. I can't use an object because keys may repeat so I use an array instead. This is how the array may look: array = ['id1', 'id5', 'id9', 'id12', '...

so I have an array in which I store values in pairs. I can't use an object because keys may repeat so I use an array instead. This is how the array may look: array = ['id1', 'id5', 'id9', 'id12', '...