如何将一个项目从一个列表移动到另一个列表? [英] How to move an item from one list to another?

查看:109
本文介绍了如何将一个项目从一个列表移动到另一个列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名新手,试图学习如何构建jQuery Mobile App,并且我有一些项目列表,我希望将这些项目列表拖到不同页面上的不同列表中.我已经弄清楚了如何使用

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. 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.

推荐答案

我认为最好的方法是动态地从JavaScript对象绘制列表.具体来说,如果您有两个列表A和B,则可能会有一个表示每个列表的字符串数组.每次在列表之间移动项目时,只需在两个数组上执行操作,然后从这些数组重新绘制列表即可.

I think the best approach would be draw your lists from JavaScript objects dynamically. Specifically, if you had two lists A and B, you might have an array of strings representing each list. 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.

我希望这会有所帮助!

这篇关于如何将一个项目从一个列表移动到另一个列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆