Ajax 选项卡淡入淡出效果问题 - jQuery 工具
使用 jQuery 工具库时,我无法使具有淡入淡出效果的 Ajax 选项卡正常工作。它只显示 ajax 调用的第一个项目的效果,但没有其他内容。
您可以在 www.excellenthost(dot)com/beta/test.php 看到测试 URL 或看到下面的代码:
JS:
<script type="text/javascript">
$(document).ready(function(){
$("ul.features-tabs").tabs(".features-panes > div.features", {
effect: 'fade',
history: true,
onBeforeClick: function(event, i) {
loaddetails(this.getTabs().eq(i).attr("id"));
function loaddetails(type) { var query = "details=" + type;
$.post("shared/details.php", query , function( data ) {
$(".features").html(data); return false;}); return false;
}; }});
});
</script>
HTML:
<div class="hostingFeatures-shadow"></div>
<div class="hostingFeatures-bg">
<div class="wrap">
<ul class="features-tabs">
<li><a id="core" href="#core">Core</a></li>
<li><a id="email" href="#email">Email</a></li>
</ul>
<div class="features-panes">
<ul class="packages-bar">
<li class="features-title"> </li>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
<!-- First Slide -->
<div class="features">
</div>
</div>
</div></div>
AJAX 内容: shared/details.php
<ul class="features-list">
<? if($_POST['details']=='core'){ ?>
<li class="features-name">Premium Disk Space</li>
<li>1000MB</li>
<li>2500MB</li>
<li>3500MB</li>
<? } if($_POST['details']=='email'){ ?>
<li class="features-name">Email Accounts</li>
<li>35</li>
<li>45</li>
<li>65</li>
<? } ?>
</ul>
正如您从示例中看到的,单击“电子邮件”选项卡时不会加载任何内容。当我执行 debugalert(data); 时,Ajax 数据正确显示,因此抓取正确的数据没有问题。这只是将其发布到实际主页上的问题
有人可以帮忙吗? 布莱恩
I am unable to get the Ajax Tabs with a fade effect to work when using the jQuery Tools library. It only shows the effect for the first item called by the ajax, but nothing else.
You may see the test URL at www.excellenthost(dot)com/beta/test.php or see the code below:
JS:
<script type="text/javascript">
$(document).ready(function(){
$("ul.features-tabs").tabs(".features-panes > div.features", {
effect: 'fade',
history: true,
onBeforeClick: function(event, i) {
loaddetails(this.getTabs().eq(i).attr("id"));
function loaddetails(type) { var query = "details=" + type;
$.post("shared/details.php", query , function( data ) {
$(".features").html(data); return false;}); return false;
}; }});
});
</script>
HTML:
<div class="hostingFeatures-shadow"></div>
<div class="hostingFeatures-bg">
<div class="wrap">
<ul class="features-tabs">
<li><a id="core" href="#core">Core</a></li>
<li><a id="email" href="#email">Email</a></li>
</ul>
<div class="features-panes">
<ul class="packages-bar">
<li class="features-title"> </li>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
<!-- First Slide -->
<div class="features">
</div>
</div>
</div></div>
AJAX Content:
shared/details.php
<ul class="features-list">
<? if($_POST['details']=='core'){ ?>
<li class="features-name">Premium Disk Space</li>
<li>1000MB</li>
<li>2500MB</li>
<li>3500MB</li>
<? } if($_POST['details']=='email'){ ?>
<li class="features-name">Email Accounts</li>
<li>35</li>
<li>45</li>
<li>65</li>
<? } ?>
</ul>
As you can see from the sample, nothing loads when 'email' tab is clicked. When I do a debug alert(data);, the Ajax data appears properly, so there is no problem with grabbing the correct data. It is only a problem of getting it posted on the actual main page
Can someone please assist?
Brian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你真的想要“淡入淡出”效果,你可以这样做:
并使用这个Javascript:
这应该可以!
If you really want the 'fade' effect, you can do this:
And use this Javascript:
That should work!
事实证明 jQuery Tools Tabs 解决方案不太适合这个,所以我为您制作了一个自定义脚本:
DEMO
它完全取消了 jQuery 工具,并且完成了您需要的所有淡入淡出和 Ajax 加载。
为了使其工作,您需要稍微更改一下 HTML:
并对 CSS 进行添加:
Turns out the jQuery Tools Tabs solution isn't very well suited for this, so I've made a custom script for you:
DEMO
It does away with jQuery Tools entirely and it does all the fading and Ajax loading you need.
To make it work, you need to change the HTML a little:
And make one addition to your CSS: