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

162 Views Asked by At

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.

2

There are 2 best solutions below

7
On BEST ANSWER

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

1
On

Checking the element seems to work http://fiddle.jshell.net/F2VKK/3/