• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to jquery load and use in codeigniter?

Hello Everybody! i'm nickname.

I had a project was using codeigniter, i built a layout and all pages used it and i used jquery to load contents(load another controller were working) into layout' contents. but those controllers could not use jquery. so :
1). i had problem with jquery in codeigniter. i could not load jquery to codeigniter and i didn't know how to load it.
2). can you help me for these problem.? it is important for me.

thanks in advance

nickname need your help.

does this help you?:

ok i saw your website. but i don't want to load jquery all view_pages of controller. i just want once load and use it all view_pages of controller.
can i autoload jquery when project run?
can u help me more...
i will show my project layout later


you could load jquery in header from google for example.
header and footer have mostly the same content on all sites.
maybe you cut your views into 3 parts/files.

the following is just systematicaly - hope I do no mistakes.
tell me if it is a help or if i can do more.

function index()
  $data['content']  = "Welcome to my homepage";
  $data['page']     = 'artikel/home';
  $this->load->view('template_view', $data);


// all header stuff and...

<#script type="text/javascript" src="http://www.google.com/jsapi?key=YOUR-GOOGLE-API-KEY">
google.load("jquery", "1.3.2");     // whatever you need
google.load("jqueryui", "1.7.2");   // whatever you need else
<#/script>              // remove the #  ;o)

if(isset($page)){ $this->load->view($page);}

echo $content;

but, yes, you can also use an autoload-way

[eluser]RaZoR LeGaCy[/eluser]
You can use an autoload but what if you do not need jquery or jquery ui on every single page. I do the same as Jan and only load jquery and other javascript when needed. It will be in one central header file anyway.

I agree with Jans' method.

hi! the good idea but my project didn't use header and footer. it was a layout (included header, footer and content) just used jquery to load the controller were working and got that result of controller's contents to displayed in content in layout. but the controller that i loaded could not use jquery except layout could use.
thanks u again that helped me. i have want u help me more about this.
- how can i autoload jquery library in codeigniter?
- what can i do with these problem?

thanks in advance.

Quote: - how can i autoload jquery library in codeigniter?
userguide: "To autoload resources, open the application/config/autoload.php file and add the item you want loaded to the autoload array. You'll find instructions in that file corresponding to each type of item."
Quote:- what can i do with these problem?
well, which one do you have then? maybe think about structure.

i still not autoload it.
can u show me some config code.?

hi! i did it.
thanks so much for your help.

see you later.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.