大佬教程收集整理的这篇文章主要介绍了jquery – 有没有办法在拖动可排序项目时刷新sortables?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
为了解决这个问题,我在我的部分列表中使用ajax进行延迟加载,只有在单击“打开部分”按钮时才从服务器获取这些项目.我们在效率低下的系统中的一个功能是用户可以在一个封闭的部分上保持拖动的项目500ms,它将打开该部分.
<ul class="sections ui-sortable" style="display: block;"> <li id="s_3" class="ui-droppable"> <input type="hidden" value="3" name="section_id"> <span class="sectionName">Section 1</span> <ul class="items ui-sortable" style=""> <!-- Items can go here --> </ul> </li> <li id="s_11" class="ui-droppable"> <input type="hidden" value="11" name="section_id"> <span class="sectionName">Section 2</span> <ul class="items ui-sortable" style="display: block;"> <li id="i_32"> <input type="hidden" value="32" name="item_id"> <span class="itemname">Item 1</span> </li> </ul> </li> </ul>
我遇到的问题是,排序功能会使用新填充的项目列表进行全部操作.
我就是这样做的,所以可以通过将鼠标悬停在列表上来打开列表:
//SELER_674_11845@ent is the .sections ul function initItemDroppable( SELER_674_11845@ent ) { SELER_674_11845@ent.find('> li').droppable({ accept: '.items > li',over: function( event,ui ) { var section = $(this); var section_id = section.find('input[name="section_id"]').val(); // only start the counter if the container isn't already visible if( !$(section).find('.items').is(':visible') ) { $( document ).oneTime( '500ms','expandCategoryTimer',function(){ //get the items and populated the list getItems( section_id ); //according to jquery,refreshes the positions of all the sortable objects $('.sections,.items').sortable('refreshPositions'); } ); } },out: function( event,ui ) { $( document ).stopTime( 'expandCategoryTimer' ); } }); }
我认为我所需要的只是关于可排序内容的“refreshPosition”方法,但它并没有完全解决问题.我被允许在列表的END处删除一个项目,但我不能将它放在其他项目之间,除非我放弃它并再次重新选择它.有任何想法吗?
以上是大佬教程为你收集整理的jquery – 有没有办法在拖动可排序项目时刷新sortables?全部内容,希望文章能够帮你解决jquery – 有没有办法在拖动可排序项目时刷新sortables?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。