在以下代码中,所有选项卡最初都会显示正确的文本(主页,报告,设置,文档,支持)。单击任何ajax选项卡(主页,文档,支持)时,选项卡上的文本将更改为“正在加载...”。但是,2个非ajax选项卡(报告和设置)保留其文本。如何防止它“加载......”为什么会改变?
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
$("#tabs").tabs();
});
</script>
</head>
<script>
$(document).ready(function() {
$("#tabs").tabs({ ajaxOptions: {cache: false}});
}
</script>
<html>
<div id="tabs">
<div id="menu">
<ul>
<li><a href="home.php" title=Home><span>Home</span></a></li>
<li><a href="#report_tabs" title=Reports><span>Reports</span></a></li>
<li><a href="#setup_tabs" title=Setup><span>Setup</span></a></li>
<li><a href="documentation.php" title=Documentation><span>Documentation</span></a></li>
<li><a href="support.php" title=Support><span>Support</span></a></li>
</ul>
</div>
</div>
</html>
答案 0 :(得分:2)
您可以将spinner
option设置为false
,或将空字符串设置为:
$("#tabs").tabs({
ajaxOptions: {cache: false},
spinner: false
});
您可以在此处查看if(o.spinner)
检查,其中任何一项都将无法通过此项检查,从而避免替换(与其他数据类型一样,但false
是IMO最明确的意图)。