开发者

jQuery sortable events

开发者 https://www.devze.com 2023-01-03 05:12 出处:网络
Im using some jQuery sortables and I basically have two event开发者_StackOverflow handlers set up in the sortable init (receive and stop) The problem is, If the receive event fires then I don\'t want

Im using some jQuery sortables and I basically have two event开发者_StackOverflow handlers set up in the sortable init (receive and stop) The problem is, If the receive event fires then I don't want the stop event to fire. In other words, it's sending two ajax requests to my server when I only need one sent.

Is there some way to check if the receive event has already fired?

Thanks!


Sample code would help some, but you can use things like $(this).data({fired: false}); to store an attribute on the Sortable. Then, in your Receive and Stop methods do something like var props = $(this).data(); if (!props.fired) { // your execution code } as a way of detecting it. Inside of the execution block you'd include a line like $(this).data({fired: true}); to record that it's been sent.


Receive event will only fire if you're dragging an item from another list. In your "stop" handler you can check which list the item has come from and do not send ajax request if it's the same list

0

精彩评论

暂无评论...
验证码 换一张
取 消