简体   繁体   English

如何将一个项目从一个列表移动到另一个列表?

[英]How to move an item from one list to another?

I'm a newbie trying to learn how to build a jQuery Mobile App and I have a list of items that I want to shuffle around to different lists on different pages. 我是一名新手,试图学习如何构建jQuery Mobile App,并且我有一些项目列表,我希望将它们拖曳到不同页面上的不同列表中。 I've been able to figure out how to remove one using 我已经能够弄清楚如何使用

$('document').ready(function() {
    $('.theListItem .red').click(function() {
        var $toRemove = $(this).closest('div[data-theme="a"]')

        $toRemove.animate({
            height: 0
        }, 500, function() {
            // This is the callback.
            $toRemove.remove();
        });

        return false;
    });
});

But if I want to move a whole item like 但是如果我想移动整个物品

<div data-role="collapsible" data-collapsed="false" data-theme="a">
    <h3>Section 1</h3>
<div data-role="controlgroup"  data-type="horizontal">
<a href="categorize.html" data-role="button">Yes</a>
<a href="index.html" data-role="button">No</a>
<a href="index.html" data-role="button">Maybe</a>
</div>

to a different list with the exact same functionality, how would u recommend I do that? 到具有完全相同功能的其他列表,您如何建议我这样做? Thanks so much. 非常感谢。

I think the best approach would be draw your lists from JavaScript objects dynamically. 我认为最好的方法是从JavaScript对象动态绘制列表。 Specifically, if you had two lists A and B, you might have an array of strings representing each list. 具体来说,如果您有两个列表A和B,则可能会有一个表示每个列表的字符串数组。 Each time you move an item between lists you just carry out the operation on the two arrays then redraw your lists from those arrays. 每次列表之间移动的项目时,你只是执行操作上的两个阵列然后从这些阵列重新绘制你的清单。

I hope this helps! 我希望这有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM