为什么 href 链接不起作用?
我有带有 2 个 tabPanel 的 tabContainer。 tabPanel 之间的转换无需页面加载,但使用 Jquery。在第二个 tabPanel 中,我有类似的内容
如果我从第二个 tabPanel 开始工作正常,但如果我从第一个 tabPanel 开始它就不起作用。为什么?我可以在不加载页面的情况下使用吗?
I have tabContainer with 2 tabPanels. Transition between tabPanels without page load but with Jquery. In second tabPanel I have something like that
<asp:CheckBoxList ID="ExstrasCheckBoxList" runat="server">
<asp:ListItem><a href="#dialog" name="modal">Additional driver</a></asp:ListItem>
<asp:ListItem><a href="#dialog2" name="modal">Baby chair</a></asp:ListItem>
<asp:ListItem><a href="#dialog3" name="modal">GPS</a></asp:ListItem>
</asp:CheckBoxList>
If I start from second tabPanel works fine, but if I start form first tabPanel it doesn't work. Why? Can I use without page loading?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有 JavaScript,我将在黑暗中进行尝试,但我假设您有类似的情况:
如果确实如此,则
$.bind
方法仅将事件侦听器附加到当前存在于 DOM 中的元素。由于您使用 AJAX 来更新 DOM,因此您的新链接没有附加任何事件侦听器。这实际上是一个非常简单的修复,只需将
$.bind
替换为$.live
即可将事件侦听器附加到现在和未来。Without your JavaScript I'm taking a shot in the dark here, but I'm assuming you have something similar to this:
If that's indeed the case, then the
$.bind
method only attaches event listeners to elements that currently exist in the DOM. Since you're using AJAX to update the DOM, your new links don't have any event listeners attached to them.It's actually a really easy fix, just replace
$.bind
with$.live
which will attach event listeners to all matched elements now and in the future.