JQM (jQueryMobile) 动态删除元素
这是此问题的第 2 部分 (好吧,也许是第 3 部分)
这是一个工作示例: http://jsfiddle.net/UcrD8/63/ 这是一个早期的尝试,您可以在选择第一个选项时看到它的工作原理: http://jsfiddle.net /UcrD8/4/ 但是使用 JQM 时,它使用它作为选项的标签,并且它是不可选择的。
添加新选择选项的功能正在工作,但如果我想删除选定的选项,则这不起作用。
更新:
我确实注意到 select 元素被删除,但 jQM 添加的语法仍在显示:
<div class="ui-select">
<div data-theme="c" class="ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-down-c ui-btn-up-c">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-btn-text">Remove Selected Option</span>
<span class="ui-icon ui-icon-arrow-d ui-icon-shadow">
</span>
</span>
</div>
</div>
也需要删除它
This is part 2 of this question (ok maybe part 3)
Here is a working example: http://jsfiddle.net/UcrD8/63/
Here is a earlier attempt and as you can see this works when selecting the first option: http://jsfiddle.net/UcrD8/4/
But using JQM it uses this as a label for the options and it is not selectable
The functionality to add a new select option is working but if I wanted to remove a selected option, this is not working.
UPDATE:
I did notice that the select element is being removed but jQM's added syntax is still displaying:
<div class="ui-select">
<div data-theme="c" class="ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-down-c ui-btn-up-c">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-btn-text">Remove Selected Option</span>
<span class="ui-icon ui-icon-arrow-d ui-icon-shadow">
</span>
</span>
</div>
</div>
Need to remove this as well
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好吧,由于 jQM 已更新多次,我能够正常工作
Well since jQM has been updated several time, I was able to get this working
我见过很多动态作品的问题。
例如,如果我在页面加载后通过 $.mobile.changePage() 创建页面元素,这些元素应该是 jquery-mobile-ified (数据角色等),它们不会成为 jquery-mobile-ified 并且在任何地方都找不到“再次解析我的页面,jquery”方法。我已经向 jquery mobile 团队记录了一个这样的错误,但我们会看看他们何时解决这个问题。可能就我自己做吧。
I've seen a lot of issues with dynamic pieces.
For example, if I create page elements after a page load via $.mobile.changePage() that are supposed to be jquery-mobilied-ified (data-role and all that), they don't become jquery-mobile-ified AND there's no "parse my page again, jquery" method to be found anywhere. I've logged a bug as such with the jquery mobile team, but we'll see when they get around to it. Might just do it myself.
当我必须删除/隐藏某个项目时,我通常将该项目包装在 div 中,然后隐藏该 div。但我不知道在这种情况下这会有多大帮助。
When I have to remove/hide an item I typically wrap the item in a div and then hide the div. I don't know how much that will help in this situation though.