0

I have implemented my own scrolling method on a jqueryui sortable list so that when the sortable helper gets close to the edge of the container the div is automatically scrolled even if the helper is stationary. This works beautifully and the behavior is exactly what I want and for this use case is far better than the built in 'scroll' functionality in jqueryUI's sortable widget itself.

However while scrolling the placeholder positions are not updated.

From delving into the jqueryui sourcecode I can see that the _rearange method is only called when the helper is being dragged. Since the container is scrolling and the helper itself is stationary, the method checking for helper/item intersects is not getting called and the placeholder position does not get updated until the user stops scrolling and then drags the helper again.

What I need to do is find a way to programmatically call the _rearange method from within my scroll interval so that the placeholder position gets updated while the container is scrolling.

How can I access these methods and properties externally?

Any help would be greatly appreciated.

4

1 回答 1

1

To access a standard widget's private method, you need two things:

1.) a reference to the selector widget's instance data 2.) name of private method you need to invoke.

You didn't post any code, so I'm going to use sample code here. But to get at sortable's "_rearrange" method, you would do something like:

$('#your-target-selector').data('sortable')._rearrange();

于 2013-02-17T19:19:48.850 回答