jquery可排序,获取最近移动元素的位置

发布于 2024-10-06 22:09:10 字数 1478 浏览 0 评论 0原文

当涉及到引用最近移动的元素时,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑,眼淚并存 2024-10-13 22:09:10

您正在寻找 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文