从 colorbox 重新加载父 div
我有一个带有购物车的 colorbox iframe。我需要重新加载显示“购物车监视器”的父 div,因为我在该 colorbox iframe 上有一个“空购物车”链接。
$("#submit<%response.write productid%>").click(function(event) {
alert('actualizo carromonitor!');
parent.$("#carromonitor").html.load("carromonitor.asp");
});
有人可以帮助我吗?
I have a colorbox iframe with a shopping-cart. I need to reload a parent div that shows a "shopping-cart monitor", because I have a "empty cart" link on that colorbox iframe.
$("#submit<%response.write productid%>").click(function(event) {
alert('actualizo carromonitor!');
parent.$("#carromonitor").html.load("carromonitor.asp");
});
Can anybody help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来你在这一行有一个错误:
jquery 中的 html() 函数应该如下所示:
但是,由于你想通过 ajax 加载它,所以不需要 html() 函数。您可以这样做:
此外,iframe 文档本身中的代码需要位于文档就绪块中。你没有提到它,所以我不知道你是否已经这样做了,但它不应该在 iframe 加载之前运行:
It looks like you have a mistake in this line:
The html() function in jquery should look like this:
However, since you want to load it via ajax, you don't need the html() function. You can do it this way:
Also, your code in the iframe document itself needs to be in a document ready block. You didn't mention it, so I don't know if you've already done that, but it shouldn't run before the iframe is loaded:
这样可以吗:
由于
#carromonitor
是一个 ID,因此应该是唯一的,因此它与单击的元素相关这一事实应该不重要。如果您要复制 ID(不应该这样做),请将$('#carromonitor')
替换为$(this).closest('#carromonitor')
一您可能遇到的问题是,第一次之后不会调用单击处理程序(假设 #submitXXX 元素位于 #carromonitor 内)。在这种情况下,请将: 替换
为
Would this do it:
Since
#carromonitor
is an ID and should therefore be unique, the fact that it's related to the clicked element shouldn't matter. If you are duplicating IDs (which you shouldn't be), replace$('#carromonitor')
with$(this).closest('#carromonitor')
One issue you might run into is that the click handler is not called after the first time (assuming that the #submitXXX element is inside #carromonitor). In that case, replace:
with