开发者

jquery dynamically loaded tab with a script inside

开发者 https://www.devze.com 2023-04-13 01:37 出处:网络
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?

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

开发者_如何学Python
<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 
   ...
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号