How to lazy load jQueryUI tab with AJAX only once?

I found a couple of examples on how to lazy load jQueryUI, but nobody is using Events / one . This seems like a good fit for the task, since it defines an event handler that is executed only once.

I can't put it all together. If I load content via AJAX by placing a link on a tab <li>

, I can't figure out how to load it once without disabling the whole link.

Has anyone thought about this?

EDIT: This might be important: I want to do this because the content of each tab contains a link to fetch another page of data. If the original AJAX link is hit every time, users will lose the page of data they are currently displaying.

+2


source to share


2 answers


If your server is sending the correct cache related headers, the first time the browser should (in theory) take care of it for you. Subsequent calls to $ (). Load ('/ url') must be caches, no?



+2


source


You are still not completely clear about your situation or needs, but if you find that one time does not suit your needs, you can create your own variable for each tab (or an array that matches the tabs by index) that records on load

var tab1loaded = false;
var tab2loaded = false;
// etc...

function loadTab1() 
{
    if (tab1loaded)
    {
        // load tab 1 data here...
        tab1loaded = true;
    }    
}

      



Low tech solution, but you have complete control over your process.

+2


source







All Articles