[英]Reload Whole Content of Tab in JQuery
First of all, with all due respect, don't ask me why I have to do this. 首先,在所有应得的尊重下,不要问我为什么必须这样做。 This request is someone request and he has his own reason.
此请求是某人的请求,他有自己的理由。 :D
:D
So just to the point... 所以只是重点...
Lets just say "p1.php" contains this code : 可以说“ p1.php”包含以下代码:
<ul>
<li><a href="#tab1">Tab 1</a></li>
<li><a href="#tab2">Tab 2</a></li>
</ul>
<div id="tab1">
<?= $_GET['somechange1'] ?>
<a onclick="actionRunOnTab1()">some change 1</a>
</div>
<div id="tab2">
<?= $_GET['somechange2'] ?>
</div>
Then I include "p1.php" in "p2.php" and added some javascript just like this : 然后,在“ p2.php”中包含“ p1.php”,并添加一些JavaScript,如下所示:
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.16.custom.min.js"></script>
<link rel="stylesheet" href="redmond/jquery-ui-1.8.16.custom.css" type="text/css" />
<div id="tab">
<? include 'p1.php'; ?>
</div>
<script language="javascript">
$(function() {
$('#tab').tabs();
});
// Some function
function actionRunOnTab1() {
$.get(
"p1.php",
{ somechange1 : 'Something to send out 1' },
function(data){
$('#tab').html(data);
$('#tab').tabs();
}
);
}
</script>
I debug the result using firebug on firefox. 我在firefox上使用firebug调试结果。 at the first creation of tab using
$('#tab').tabs();
在使用
$('#tab').tabs();
首次创建标签时 , it added some css class to all needed elements to create tab, but at the second time I use $('#tab').tabs();
,它向所有需要的元素中添加了一些CSS类来创建标签,但是第二次我使用
$('#tab').tabs();
at function actionRunOnTab1
it doesn't have any effect. 在函数
actionRunOnTab1
上没有任何作用。
How can I refresh all tabs? 如何刷新所有标签? If I reload 1 by 1 of tab it sure needs more extra $.get() which means need more than once to connect to server.
如果我按选项卡的1对1重新加载,则肯定需要更多的$ .get(),这意味着需要多次连接到服务器。
要以编程方式重新加载Ajax选项卡,请调用load
event
并提供相关的选项卡索引。
$('#mytabs').tabs( "load" , index );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.