JQuery UI Tabs with $ (document) .ready equivalent

I am trying to use jQuery UI tabs in the same way as the master page in ASP.Net. I have a custom javascript that needs to be run after each tab is loaded. I tried to have $ (document) .ready function on every page, but I read this bad practice and only seems to work in IE.

I know there is a load event, but I need the event to be specific to each tab, and I'm not sure how to do this, or if it is possible. I may have to go back to using and actual MasterPage with postback for every page load.

0


a source to share


3 answers


Where did you read that this is bad practice?



Afaik, which has several $(document).ready()

, will simply make them a "merge" so that all the code that is in any of them will run. I don't remember if this is new in jQuery 1.3 , so you can check it out.

+1


a source


$(document).ready()

is a good practice and it works in every browser that jQuery runs on. If your events are only firing in IE, you have a bug somewhere in your own code.



I have dozens of ready-made functions in my applications and no problems.

+2


a source


It's a good practice to have several $().ready

, unless you break it down into several. In case the tab is loaded in ajaxily IMHO puts $ (document) .ready inside the loaded contentis probably the best way to do some tab-related actions. I use this to re-bind the newly loaded items as they are being entered into the newly loaded tab.

+1


a source







All Articles