jQuery:使用切换按钮在多个列表之间移动项目
我有三个列表,每个项目都有一个按钮工具栏。这些列表是上演的、实时的和固定的。我正在尝试使用切换按钮在列表之间移动项目。正如您从下面的 jsfiddle 示例中看到的,我有移动项目的按钮,但我遇到了两个问题,我希望得到一些帮助。我是一个视觉学习者,我在 Stackoverflow 和 Google 上都找过例子,但没有成功。
注释 - 编辑和垃圾按钮不会移动项目。我将在每个切换操作中执行 ajax 调用来提交每个更改,我在 js 文件中注意到了这一点。
工作示例: http://jsfiddle.net/RuRdZ/3/
问题:
1 - 当您单击按钮时,例如暂存列表中的“实时”,该项目会正确移动到实时列表,但该项目上的按钮似乎被禁用 - 移动后我无法删除该项目或者让它再次上演。这将是一个问题,因为我的目标是不刷新页面。
2 - 当将一个项目从一个列表移动到另一个列表时,我试图弄清楚如何使正确的按钮消失/出现。例如,如果我使一个暂存项目处于活动状态,当该项目移动时,我想隐藏“使活动”按钮并显示“舞台”按钮。我已经尝试了几件事,但我认为我没有使用正确的选择器。在每个标题中,我列出了应出现在每个列表中的正确按钮。
感谢您的帮助!
I have three lists, each item has a tool bar of buttons . The lists are staged, live and pinned. I'm trying to use the toggle buttons to move the items between the lists. As you can see from the jsfiddle example below, I have the buttons moving the items, but I've encountered two problems I was hoping to get some help with. I'm a visual learner, I've looked all over Stackoverflow and Google for an example with no luck.
Notes - The edit and trash buttons don't move items. I will be executing an ajax call within each toggle action to commit each change, I noted this in my js file.
Working Example: http://jsfiddle.net/RuRdZ/3/
The Problems:
1 - When you click on a button, for example 'Make Live' in the staged list, the item properly moves to the live list but the buttons on this item seem to become disabled - after the move I cannot delete the item or make it staged again. This will be a problem because my goal is to not have the page refresh.
2 - Again when moving an item from list to list, I was trying to figure out how to make the proper buttons disappear/appear . For example if I make a staged item live, when the item moves, I'd like to hide the 'make live' button and show the 'stage' button. I've tried several things but I don't think I'm using the right selector. In each heading I listed the proper buttons that should appear in each list.
Thank you for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要使用克隆,将现有元素附加到另一个元素会将其从原始容器元素中删除 - 它解决了按钮事件
在一个处理程序中执行所有操作的问题 - 然后您将获得对按钮的控制以相应地显示或隐藏它们,
例如
do not use clone, appending existed element to another one removes it from original container element - it solves the problem with buttons events
do all actions in one handler - then you'll get the control over buttons to show or hide them accordingly
e.g.