![]() |
best way to handle several body onload - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: best way to handle several body onload (/showthread.php?tid=39389) |
best way to handle several body onload - El Forum - 03-09-2011 [eluser]zenon[/eluser] Hi, I'm using jquery routine to init all elements where body document is laoded. Code: $(document).ready(function(){ How could I handle this routine for each page? One solution may be to build a first common header part and another specified on each controller, but another solution I heard could be to inject a javascript source still from controller. Have you ever hear about this? However, which approach do you use? Thank you ![]() best way to handle several body onload - El Forum - 03-09-2011 [eluser]R_Nelson[/eluser] can you give an example of what your trying to do your question seems a bit vague to me best way to handle several body onload - El Forum - 03-09-2011 [eluser]Namaless[/eluser] Code: jQuery(document).ready(function() { This is only simple example to use with Code: $this->load->view( 'jquery_script' ); best way to handle several body onload - El Forum - 03-09-2011 [eluser]joakley77[/eluser] Not sure exactly what you're trying to do but why not use one .js file and do whatever you need to do if the element is visible? Code: $(document).ready(function() { best way to handle several body onload - El Forum - 03-09-2011 [eluser]bubbafoley[/eluser] you can have multiple document ready functions http://www.learningjquery.com/2006/09/multiple-document-ready best way to handle several body onload - El Forum - 03-09-2011 [eluser]zenon[/eluser] [quote author="Namaless" date="1299719143"] Code: This is only simple example to use with [CODE]$this->load->view( 'jquery_script' ); What stands for jquery_script? Is it a .js ? If so, I would keep the script tag inside head element, as w3c suggests. A possible solution would be Code: $this->load->view( 'header_first_part' ); // open <head> element best way to handle several body onload - El Forum - 03-09-2011 [eluser]zenon[/eluser] [quote author="bubbafoley" date="1299724923"]you can have multiple document ready functions http://www.learningjquery.com/2006/09/multiple-document-ready[/quote] I can't figure out how use it. Can you make a more accurate example please? thank you! ![]() |