以编程方式重新加载 Ajax 选项卡内容时出现问题?
如何在运行时动态设置 jQuery 的 ajax 选项卡的 url?
这样做:
$(function() {
//$("#tabs").tabs();
$("#tabs").tabs("url" , 0, "dep.php" );
});
html
<div class="flts">
<div id="tabs">
<ul>
<li><a href="dep.php">Вылеты</a></li>
<li><a href="arr.php">Посадка</a></li>
</ul>
</div>
</div>
但它不起作用!可能有什么问题?
How can I set jQuery's ajax tab's url dynamically in runtime?
Doing like this:
$(function() {
//$("#tabs").tabs();
$("#tabs").tabs("url" , 0, "dep.php" );
});
html
<div class="flts">
<div id="tabs">
<ul>
<li><a href="dep.php">Вылеты</a></li>
<li><a href="arr.php">Посадка</a></li>
</ul>
</div>
</div>
but it's not working! What could be a problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的做法似乎不正确。
$("#tabs").tabs("url" , 0, "dep.php")
的调用被包装在$(function() {
中,因此它仅在页面第一次加载时运行,这是没有意义的。正确的方法是:
页面应该只包含带有有效链接的选项卡标签 。选项卡内容。
首次加载页面时,调用
$("#tabs").tabs();
初始化并配置选项卡小部件。< /p>现在可以使用选项卡小部件并加载选项卡内容 。当第一次显示特定选项卡时(延迟加载)
$("#tabs").tabs("url" , 0, "dep.php")< /code>
因此,整体解决方案可能如下所示:
Your approach doesn't seem correct. The call of
$("#tabs").tabs("url" , 0, "dep.php")
is wrapped in$(function() {
, so it's run only the first time the page is loaded. That makes no sense. This method is used to later replace the tab content.The correct is approach is:
The page should only contain the tab label with a valid link but no tab content.
When the page is first loaded, call
$("#tabs").tabs();
to intialize and configure the tab widget.The tab widget is now usable and the tab content is loaded when the specific tab is displayed for the first time (lazy loading).
$("#tabs").tabs("url" , 0, "dep.php")
.So the overall solution could look like this:
看来您正在尝试使用 AJAX 模式。如果是这种情况,那么您需要指定 ajaxOptions。 此页面有一个简单的示例,应该可以让您明白。
It looks like you're trying to do the AJAX mode. If that be the case, then you need to specify the ajaxOptions. This page has a simple example which should set you straight.