Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with bootstrap collapse #4

Open
malutka opened this issue Apr 7, 2014 · 4 comments
Open

Doesn't work with bootstrap collapse #4

malutka opened this issue Apr 7, 2014 · 4 comments

Comments

@malutka
Copy link

malutka commented Apr 7, 2014

I'm using Bootstrap and this plugin. I created collapse menu - menu doesn't close when I'm using unevent plugin.

@LPABelgium
Copy link

Same issue with collapse and modal

@prwaves
Copy link

prwaves commented Jun 15, 2016

One quick solution is to simply edit the plugin and rename the method so that it doesn't overwrite the .on() function. Then explicitly call the new method when desired, instead of relying on the existence of a third parameter to determine if it should be triggered. This would avoid affecting any other plugins depending on the .on() function.

@gaspard-macelin
Copy link

Hi @prwaves can you help me?
I change juste the .on ?

;(function ($) {
var on = $.fn.on, timer;
$.fn.on = function () {
var args = Array.apply(null, arguments);
var last = args[args.length - 1];

            if (isNaN(last) || (last === 1 && args.pop())) return on.apply(this, args);

            var delay = args.pop();
            var fn = args.pop();

            args.push(function () {
                    var self = this, params = arguments;
                    clearTimeout(timer);
                    timer = setTimeout(function () {
                            fn.apply(self, params);
                    }, delay);
            });

            return on.apply(this, args);
    };

}(this.jQuery || this.Zepto));

thanks a lot

@gaspard-macelin
Copy link

Ok this one is good

thanks @jpouillard

;(function ($) {

$.fn.afterEvent = function () {

var args = Array.apply(null, arguments);
var last = args[args.length - 1];

if (isNaN(last) || (last === 1 && args.pop())) return $.fn.on.apply(this, args);

var delay = args.pop();
var fn = args.pop();

args.push(function () {

  var self = this;
  var params = arguments;

  if (!this.timer) this.timer = {};
  if (this.timer[delay]) clearTimeout(this.timer[delay]);

  this.timer[delay] = setTimeout(function () {
    fn.apply(self, params);
  }, delay);
});

return $.fn.on.apply(this, args);

};
}(this.jQuery));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants