You could try the .stop()
function before slideToggle()
.
desplegable.stop(true, false).slideToggle('normal');
API: http://api.jquery.com/stop/
When things become more complicate (callbacks, ...) it could be nice to wrap everything inside an eventHandler.
// ignore fast events, good for capturing double click
// @doc (event.timeStamp): http://api.jquery.com/event.timeStamp/
// @bug (ev.currentTime): https://bugzilla.mozilla.org/show_bug.cgi?id=238041
ignoredEvent: (function () {
var last = {},
diff, defEvent;
return function (callback, time, id) {
defEvent = this.defaults.events.ignore; // object: { id: "event", ms: 300 }
id = id || defEvent.id;
diff = last[id] ? time - last[id] : time;
if (diff > defEvent.ms) {
last[id] = time;
callback();
}
};
})();
Just make sure the current time can be achieved x-browser. (new Date).getTime()
can help instead of event.currentTime
or event.timeStamp
.
My implementation example goes something like this:
container.navigation.click(function (ev) {
ev.preventDefault();
helpers.ignoredEvent(function () {
// do your thing here
}, (new Date).getTime());
});