0

I have a square grid with 5*5 squares inside it. I want to swap two squares (ie) when i drag a square and drop it on another square both the squares should get swapped changing their positions. But since am using sortable some other squares positions are getting changed. Is this behaviour possible in knockout js ???

4

1 回答 1

0

sortable绑定接受一个beforeMove回调,该回调传递一个包含sourceParentsourceIndextargetParent和的对象targetIndex。您可以使用它们自己进行交换。

此外,您可以设置arg.cancelDrop = true;为指示您将自己处理。

这是一个示例:http: //jsfiddle.net/rniemeyer/c7NLz/

于 2013-03-07T14:39:56.340 回答