Script.aculo.us Sort by IssueUpdate in IE

I am working on a project where I am using the script.aculo.us Sortable object.

It works nice and fast in Firefox and Chrome, but in IE it is incredibly slow when I drop the element.

I checked a little check and it turns out that in IE the onUpdate callback is called about 8 times every time I cast. It is usually assumed that it will only be called once per container being sorted (destination and origin).

Since my callback function resizes some of the elements and draws graphics on those elements, the computation involved in each call is significant.

Does anyone know what might be causing this issue in IE, or how to fix it?

EDIT: I noticed that the problem is not that it is triggered many times when it is dragged, the problem is that the function is onUpdate

triggered when the order of the sorted changes is changed, even if the drag has not finished yet. Seems to onUpdate

work like a callback onChange

, but only IE.

0


source to share


2 answers


I think you are using the timer incorrectly. You only want the timer to start once, after a timeout. If something is still happening during the timeout, you need to reset the timer and start over, otherwise you just delay what you do in the first place.



var timer1
Sortable.create("fList", {constraint:false,onChange:function(){triggerUpdate()}})

function triggerUpdate() {
    clearTimeout(timer1)
    window.setTimeout(function(){showList()},800)
}
function showList() {
    var now = new Date()
    alert(now)

}

      

+1


source


I don't know about script.aculo.us, but when events are resized, IE constantly fires events, not just after resizing (as most other browsers do), so I guess onUpdate internally works based on something else that fires (like resizing) multiple times.

One trick I've used for similar problems is when an event fires, set the action to "action" after a timeout (eg 1/4 sec) ... but every new event triggers a "clear" timeout. so all you get is the "last" event.



If anyone knows what script.aculo.us actually runs, I could provide more details.

+1


source







All Articles