2013-03-06 174 views
1

我正在使用jQuery UI垂直選項卡,並通過AJAX加載內容。我嘗試了幾乎所有從這裏的帖子,並沒有幫助我到目前爲止..:/jQuery UI Ajax選項卡加載不顯示

我想顯示一個css3加載動畫放置在<div id="loading-image">...</div>。迄今幾乎沒有任何事情發生。

我的代碼

$(function() { 
    $("#messages_tabs_div").tabs({ 
     beforeLoad: function(event, ui) { 
      console.log(ui); 
      ui.jqXHR.error(function() { 
       ui.panel.html("Couldn't load your messages. Try refreshing your page."+ 
        " If you think this is bug you can help us by submitting it at [email protected] " ); 
      }); 
      ui.jqXHR.complete(function(response){     
       console.log(response);      
      }); 
     }, 
     disabled: [6], 
     select: function(event, ui) { 
      alert('ASDAD'); 
     } 
    }).addClass("ui-tabs-vertical ui-helper-clearfix"); 
    $("#messages_tabs_div li").removeClass("ui-corner-top").addClass("ui-corner-left"); 
}); 

//jQuery MINE 
$(document).ready(function(){ 
    $('#loading-image').hide(); 
    //Set loading bar for all ajax requests 
    $('#loading-image').bind('ajaxStart', function(){ 
     alert('AJAXXX'); 
     $(this).show(); 
    }).bind('ajaxStop', function(){ 
     $(this).hide(); 
    });  

    $('#loading-image').bind('tabsselect', function(event, ui) { 
     alert('TABSSSSS'); 
     $(this).show(); 
    }).bind('tabsload', function(event, ui) { 
     $(this).hide(); 
    }); 
}); 

我唯一得到的是AJAX alert。我試圖刪除$('#loading-image').hide();和加載總是在那裏。

請幫助....

預先感謝您

+0

請問您可以添加html(標題和內容應該在同一個容器中),如果您想分開標題和內容您可以使用[jquerytools選項卡](http://jquerytools.org/demos /tabs/index.html) – 2013-03-06 19:35:21

回答

2

我建議使用全局AJAX中..

$(document).ajaxStart(function() { 
    $("#loading").fadeIn(200); 
}).ajaxStop(function() { 
    $("#loading").fadeOut(300); 
}).ajaxSuccess(function() { 
}); 

但是,如果你想個性化的多個事件,請參閱這個問題:

How to call .ajaxStart() on specific ajax calls

jQuery should I use multiple ajaxStart/ajaxStop handling

+0

它不工作..這就是我說的..我已經嘗試過了......我不知道問題在哪裏。即使當加載顯示,當我點擊任何其他標籤隱藏.. FOREVER ..:/ – Bankin 2013-03-06 19:35:09

+0

嘗試做一些在線演示,並試圖幫助你更好 - http://jsfiddle.net/ – Guilherme 2013-03-06 19:36:17

+1

發現我的錯誤,我把加載div在其中一個選項卡,當我切換選項卡它消失..我很愚蠢:D感謝您的幫助無論如何:) – Bankin 2013-03-06 19:47:07

相關問題