开发者

Can jQuery UI's Sortable handle complex selectors for the items option?

I have list items in an unordered list that when double clicked, can be edited in place via a wysiwyg editor.

$('ul.m开发者_JAVA百科tm_section').sortable({
  disabled: true,
  distance: 10,
  items: '> li:not(:has(form))'
});

My goal is to prevent the list item from being sorted while it is being edited - aka once a form element has been swapped in place of the contents.

Unfortunately my selector for items is not working. Is sortable able to handle complex selectors like these? If not, are there other clever means to disable some items from being sortable, perhaps a callback function?

I would prefer to rely on this sortable option, as the wysiwyg plugin is deeply nested with jEditable and as far as I know does not open up any events for me to hook into.

Using jQuery 1.4.2 and jQuery UI 1.8.1


jQuery UI Sortable accepts any selector, but the selector is used to choose which items are sortable when the sortable is created—not when a drag starts. If you change the DOM, it will still remember which items were sortable when the sortable was created.

You should be able to return false from sortstart if ui.item contains a <form>, but this seems to not work right now; instead, you can use this, which does:

$('ul').sortable({
  items: '> li',
  cancel: 'li:has(form)'
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜