jqueryeventsjointjsrappid

How to access an element's object on a halo event handler?


When customizing events for the Rappid Halo tool handles, the arguments variable seems to only have the jQuery.Event object and the x and y coordinates.

How can I get the cell/element or cellView in order to work on it?


Solution

  • The Element's View can be found through this.options.cellView. Example for a removal handle:

    {
      name: 'remove',
      position: 'ne',
      events: {
        pointerdown: function (evt) {
          evt.stopPropagation();
          var elementView = this.options.cellView;
    
          // work on the element ...
          elementView.model.remove();
         }
      }
    }
    

    In this particular example, if the goal was to exclusively remove the element, then there is no need for a customized function, i.e.: events: {pointerdown: 'removeElement'}.