Search code examples
mootoolsmootools-sortable

I have to attach two event (click and sortable) on one element


here is the problem,I have to attach two event (click and sortable) on one element,but when i click the element,it also trigger sortable complete event. Is there any way to solve this? I saw the source code of sortables,it bind mousedown event,so it will trigger by click.while how can i deteted whether is fired by click or drag.

otherwise,if there is a good way to detect element resort or not will be fine.


Solution

  • One option, pointed out by Timmeh at the #mootools irc, is to use the onSort event and have a flag there.

    Like:

    onSort: function () {
        this.sorted = true;
    },
    onComplete: function (el) {
        if (this.sorted) {
            alert("complete trigger complete");
        }
        this.sorted = false;
    }
    

    Fiddle