JQuery UI let us have tabs loaded dynamically:

http://jqueryui.com/demos/tabs/#ajax

My question is: if the dynamically loaded tab needs scripts, how do I need to write them?

Should I use a $(document).ready method again? like that:

Tab1.html

<script>
    $(document).ready(function () {
       alert("hello");
    });
</script>
<p>Tab Content</p>

----------------- end of tab1.html -----------------

In this example the alert shows each time the tab is displayed.

有帮助吗?

解决方案

When creating your tabs, you need to set cache:true like this:

$("#tabsWrap").tabs({
   ...
   cache: true 
   ...
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top