Jump to content

[Javascript] Multiple invocation


Recommended Posts


I'm making a small plugin which adds buttons to every post in the topic:

<li data-controller="plugins.coolAction">
  <button data-action="someAction" data-name="{$comment->author_name}">Make an action</button>

In the coolAction.js I'm catching a click event:

;(function($, _, undefined){
  "use strict";

  ips.controller.register('plugins.coolAction', {

    initialize: function () {
      this.on( document, 'click', '[data-action="someAction"]', this.mention );

    mention: function (e) {

      alert($( e.currentTarget ).attr('data-name'));

}(jQuery, _));

But this action is invocated multiple times when I click on a button. Why?

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...