jquery可排序,获取最近移动元素的位置
当涉及到引用最近移动的元素时,Jquery sortable 似乎真的很令人困惑...所以假设我有这个列表:
<ul id="slides-large-list-scroll" style="height: 770px; " class="ui-sortable">
<li style="background-color: #ff7d7d" value="2" class="pages-anchor"><a class="goto" id="linkto2" href="#2"><img src="http://localhost/Negar/thumbnail/sina_lol_2.png" class="thumbnail" id="thumbnail-2"> </a> </li>
<li style="background-color: rgb(255, 125, 125); " value="1" class="pages-anchor"><a class="goto" id="linkto1" href="#1"><img src="http://localhost/Negar/thumbnail/sina_lol_1.png" class="thumbnail" id="thumbnail-1"> </a> </li>
<li style="background-color: #ff7d7d" value="3" class="pages-anchor"><a class="goto" id="linkto3" href="#3"><img src="http://localhost/Negar/thumbnail/sina_lol_3.png" class="thumbnail" id="thumbnail-3"> </a> </li>
<li style="background-color: #ff7d7d" value="4" class="pages-anchor"><a class="goto" id="linkto4" href="#4"><img src="http://localhost/Negar/thumbnail/sina_lol_4.png" class="thumbnail" id="thumbnail-4"> </a> </li>
</ul>
并且我正在使用这个:
$('#slides-large-list ul')
.sortable({
axis: 'y',
update: function(event, ui) {
Nx.movePage($(this).eq());
}
});
所以我非常想将最近移动的元素的 eq 值传递给 Nx.movePage () 函数,但我不能,并且文档不足以解释事件和 ui 所指的内容。请帮忙! :)
Jquery sortable seems really confusing when it comes to referring to the recently moved element ... so let's say I have this list :
<ul id="slides-large-list-scroll" style="height: 770px; " class="ui-sortable">
<li style="background-color: #ff7d7d" value="2" class="pages-anchor"><a class="goto" id="linkto2" href="#2"><img src="http://localhost/Negar/thumbnail/sina_lol_2.png" class="thumbnail" id="thumbnail-2"> </a> </li>
<li style="background-color: rgb(255, 125, 125); " value="1" class="pages-anchor"><a class="goto" id="linkto1" href="#1"><img src="http://localhost/Negar/thumbnail/sina_lol_1.png" class="thumbnail" id="thumbnail-1"> </a> </li>
<li style="background-color: #ff7d7d" value="3" class="pages-anchor"><a class="goto" id="linkto3" href="#3"><img src="http://localhost/Negar/thumbnail/sina_lol_3.png" class="thumbnail" id="thumbnail-3"> </a> </li>
<li style="background-color: #ff7d7d" value="4" class="pages-anchor"><a class="goto" id="linkto4" href="#4"><img src="http://localhost/Negar/thumbnail/sina_lol_4.png" class="thumbnail" id="thumbnail-4"> </a> </li>
</ul>
and I'm using this :
$('#slides-large-list ul')
.sortable({
axis: 'y',
update: function(event, ui) {
Nx.movePage($(this).eq());
}
});
so pretty much I want to pass eq value of recently moved element to Nx.movePage() function, but I can't, and the documentation is not sufficient to explain what event and ui refer to. please help ! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在寻找
ui.item
。您是对的,有关更新事件的文档并不广泛,但是当有疑问时,
console.log
一切都可以。在您的函数中尝试以下操作:
console.log(ui);
当您看到该对象在控制台中弹出时,单击该对象。查看所有这些有用的属性。所以基本上
Nx.movePage(ui.item);
应该适合你。You're looking for
ui.item
.You're correct that the documentation on the update event isn't extensive, but when in doubt,
console.log
everything.Try the following in your function:
console.log(ui);
Click on that object when you see it popup in the console. Check out all of those helpful properties.So basically
Nx.movePage(ui.item);
should work for you.