i have customer table in which i have column for customer name which is hyperlink. Now on click of hyperlink i am adding jquery tabs on the fly(thru ajax) which brings response(html + javascript) from server. As i click on customer1 hyperlink,its details are shown under Customer1 tab(Basically html reponse gets appended under Customer1 tab and also javascript associated with in that response also executed on browser).Similarly for customer 2. Issue is when i comeback to Customer1 Tab , Content shown is correct but javascript associated with Customer1 Tab response is not executed. This happens when use cache:true option.

var tabs = $("#myTabs").tabs({

tabTemplate: 'tabTemplate',

add: function (event, ui) {

/add specific logic

},

cache:true

});

If i use cache:false option, everything works like charm because each time response is coming from server and latest javascipt is execute and remains in browser context. But when i use cache:true() javasvcript associated with tab response is not executed (so what happens is javascripr that came from server lastly remains in browser context and creates issues .

For example if i do some operation on tab (i am coming back to), i don't get the javascript data associated with that specific tab response (instead i see the data associated with the tab for which last call was made to server).

In nutshell is there a way i can the make the javascript(associated with tab) to execute while using option cache as true?(so that right javascript can be put in browser context)

Folks to me it looks a bug as javascript does not get executed when i come back to tab and use tab caching.I raised the issue against it at http://bugs.jquery.com/ticket/13681 but it got closed stating where resolution iset to not a bug.

JavaScript never executes just because an element is shown. I'm not sure why you expect this to happen. If you have cache turned off, you're requesting the content again, which has the inline script and so it runs again. You should redesign your code. Use the callbacks/events that the tabs widget provides.

Scott , i completely agree with you that JavaScript never executes just because an element is shown. But the issue is when i dynamically add tab, each tab has its own specific javascript (Just for example each tab has javascript global variable customer id, whose value is different for each tab. There are bunch of stuff like this). Now when i use caching and come back to tab for which content has already been fetched once, CustomerId is dirty(as in browser context customer Id is for last ajax request not for the tab i am coming back to)

As you mentioned that "If you have cache turned off, you're requesting the content again, which has the inline script and so it runs again". I am wondering is there a way or configuration so that i can tell jquery tabs to execute javascript associated with that tab.

I did look into load function of jquery-ui-1.8.12.custom.js and found below code snippet that gets executed