Welcome Guest, Not a member yet? Register   Sign In
how to jquery load and use in codeigniter?
#11

[eluser]tkyy[/eluser]
i usually do this one of two ways:

1. (when i am being neat and formal and i want to focus on future editability): i create an assets directory in the project root and load a "ready file" basically a jquery file calling $().ready(function(){}); for that page. i pass the ready file name to the header when i load it onto the page, ie:

Code:
$this->load->view('internal_header',array('title'=>'Dashboard','ready'=>'dashboard.js'));

when i do it this way it is very formal, i don't pass any php variables to the javascript whatsoever, i pull variables from the dom element and insert them into the ajax posts.

2. (when i am being sloppy and want something done fast for a client and they don't really want revisions or future editability): i throw jquery into the header file and then i write all the javascript at the bottom of each respective page using $().ready(function(){}); inside of [removed] tags. this is not ideal as the jquery behavior will "load late" if you do it this way, but it is the easiest in terms of development and usually doesn't make a difference to a naive client who wants a cms done.

i have found actually working with jquery the 2nd way is faster in terms of development instead of doing page reloads, what i mean by this is i can actually write the code faster performing ajax posts and not reloading pages in comparison to traditional php post/get etc. its really odd but it works for me.
#12

[eluser]nickname[/eluser]
thanks




Theme © iAndrew 2016 - Forum software by © MyBB