CodeIgniter Forums
how to jquery load and use in codeigniter? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: how to jquery load and use in codeigniter? (/thread-32676.html)

Pages: 1 2


how to jquery load and use in codeigniter? - El Forum - 07-30-2010

[eluser]nickname[/eluser]
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.


how to jquery load and use in codeigniter? - El Forum - 07-30-2010

[eluser]Jan_1[/eluser]
does this help you?:
http://spyrestudios.com/simple-guide-how-to-get-started-with-jquery/


how to jquery load and use in codeigniter? - El Forum - 07-31-2010

[eluser]nickname[/eluser]
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

thanks..


how to jquery load and use in codeigniter? - El Forum - 08-01-2010

[eluser]Jan_1[/eluser]
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.

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

template_view.php
Code:
<?php
$this->load->view('template/header');
$this->load->view('template/content');
$this->load->view('template/footer');
?>

header.php
Code:
// 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)

content.php
Code:
&lt;?php
if(isset($page)){ $this->load->view($page);}
?&gt;

home.php
Code:
&lt;?php
echo $content;
?&gt;



how to jquery load and use in codeigniter? - El Forum - 08-01-2010

[eluser]Jan_1[/eluser]
but, yes, you can also use an autoload-way


how to jquery load and use in codeigniter? - El Forum - 08-01-2010

[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.


how to jquery load and use in codeigniter? - El Forum - 08-02-2010

[eluser]nickname[/eluser]
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.


how to jquery load and use in codeigniter? - El Forum - 08-02-2010

[eluser]Jan_1[/eluser]
mmh,..
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.


how to jquery load and use in codeigniter? - El Forum - 08-03-2010

[eluser]nickname[/eluser]
i still not autoload it.
can u show me some config code.?




how to jquery load and use in codeigniter? - El Forum - 08-03-2010

[eluser]nickname[/eluser]
hi! i did it.
thanks so much for your help.

see you later.