Skip to main content
improved formatting
Source Link
palacsint
  • 30.4k
  • 9
  • 82
  • 157

JqueryTools jQueryTools plugin custom effect for caching ajaxed tabsctabs

This is a custom effect for jQuery tools that enable caching for ajaxed tabs. Please advice on anything that I can improve. Note that I'm not sure where to put the loading indicator, so, at least have a look at that. Thanks.

$.tools.tabs.addEffect("ajax_cache", function(tabIndex, done) {
    //check if content already loaded
    //if yes, display it, and hide the rest
    //if no, send ajax request

    var panes_cont = this.getPanes().eq(0);
    var dest_pane = panes_cont.find("#tabindex_"+tabIndex);
    if(dest_pane.length > 0){
        panes_cont.children().hide();
        dest_pane.show();
    } else {
        panes_cont.children().hide();
        panes_cont.append("<img id='tab_loading' src='/graphics/loading.gif' />");
            
        var new_pane = $('<div>').attr('id', 'tabindex_'+tabIndex).load(this.getTabs().eq(tabIndex).attr("href"),
        function(){
            panes_cont.find("#tab_loading").remove();
            panes_cont.append(new_pane.show());
        });
            
    }
        
    done.call();
});

JqueryTools plugin custom effect for caching ajaxed tabs

This is a custom effect for jQuery tools that enable caching for ajaxed tabs. Please advice on anything that I can improve. Note that I'm not sure where to put the loading indicator, so, at least have a look at that. Thanks.

$.tools.tabs.addEffect("ajax_cache", function(tabIndex, done) {
    //check if content already loaded
    //if yes, display it, and hide the rest
    //if no, send ajax request

    var panes_cont = this.getPanes().eq(0);
    var dest_pane = panes_cont.find("#tabindex_"+tabIndex);
    if(dest_pane.length > 0){
        panes_cont.children().hide();
        dest_pane.show();
    } else {
        panes_cont.children().hide();
        panes_cont.append("<img id='tab_loading' src='/graphics/loading.gif' />");
            
        var new_pane = $('<div>').attr('id', 'tabindex_'+tabIndex).load(this.getTabs().eq(tabIndex).attr("href"),
        function(){
            panes_cont.find("#tab_loading").remove();
            panes_cont.append(new_pane.show());
        });
            
    }
        
    done.call();
});

jQueryTools plugin custom effect for caching ctabs

This is a custom effect for jQuery tools that enable caching for ajaxed tabs. Please advice on anything that I can improve. Note that I'm not sure where to put the loading indicator, so, at least have a look at that.

$.tools.tabs.addEffect("ajax_cache", function(tabIndex, done) {
    //check if content already loaded
    //if yes, display it, and hide the rest
    //if no, send ajax request

    var panes_cont = this.getPanes().eq(0);
    var dest_pane = panes_cont.find("#tabindex_"+tabIndex);
    if(dest_pane.length > 0){
        panes_cont.children().hide();
        dest_pane.show();
    } else {
        panes_cont.children().hide();
        panes_cont.append("<img id='tab_loading' src='/graphics/loading.gif' />");
            
        var new_pane = $('<div>').attr('id', 'tabindex_'+tabIndex).load(this.getTabs().eq(tabIndex).attr("href"),
        function(){
            panes_cont.find("#tab_loading").remove();
            panes_cont.append(new_pane.show());
        });
            
    }
        
    done.call();
});
Tweeted twitter.com/#!/StackCodeReview/status/198324844230742017
Source Link
Sufendy
  • 131
  • 2

JqueryTools plugin custom effect for caching ajaxed tabs

This is a custom effect for jQuery tools that enable caching for ajaxed tabs. Please advice on anything that I can improve. Note that I'm not sure where to put the loading indicator, so, at least have a look at that. Thanks.

$.tools.tabs.addEffect("ajax_cache", function(tabIndex, done) {
    //check if content already loaded
    //if yes, display it, and hide the rest
    //if no, send ajax request

    var panes_cont = this.getPanes().eq(0);
    var dest_pane = panes_cont.find("#tabindex_"+tabIndex);
    if(dest_pane.length > 0){
        panes_cont.children().hide();
        dest_pane.show();
    } else {
        panes_cont.children().hide();
        panes_cont.append("<img id='tab_loading' src='/graphics/loading.gif' />");
            
        var new_pane = $('<div>').attr('id', 'tabindex_'+tabIndex).load(this.getTabs().eq(tabIndex).attr("href"),
        function(){
            panes_cont.find("#tab_loading").remove();
            panes_cont.append(new_pane.show());
        });
            
    }
        
    done.call();
});