jquery mobile阻止replaceWith div更新?
我有一个工作购物车系统,其中通过 jquery ajax 调用将商品添加到购物车,并使用 replaceWith
更新请求页面上的 div 以反映商品数量和金额。效果很好。 (顺便说一下,这个 div 出现在每个页面的页眉中)。
我现在正在开发 jquery mobile (Alpha 4) 版本。商品已添加到购物车,但相关 div 不再更新。不起作用的特定代码是:
$("#cartsummary").replaceWith(html);
我真的很感激对此的任何想法。
I have a working shopping cart system in which items are added to the shopping cart via jquery ajax calls, and a div on the requesting page is updated using replaceWith
to reflect the number of items and amount. It works great. (Incidentally, this div appears in the header of every page).
I'm now working on a jquery mobile (Alpha 4) version. Items get added to the shoppingcart, but the div in question is no longer updated. The particular code that isn't working is:
$("#cartsummary").replaceWith(html);
I would really appreciate any thoughts on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我想我已经明白了。 JQM 将连续的页面添加到现有 DOM,将每个页面包装在一个 id 中,以便按后退按钮不需要加载页面。这意味着一个页面上可以有我的“cartsummary”id 的多个副本。这显然行不通。我把id改成了class,就成功了。
OK, I think I figured it out. JQM adds successive pages to the existing DOM, wrapping each in an id, so that pressing the back button doesn't require a page load. This means that there can be several copies of my "cartsummary" id on a page. That obviously wouldn't work. I changed the id to an class, and it worked.