Welcome Guest, Not a member yet? Register   Sign In
Jquery & CodeIgniter
#1

[eluser]skyrocket777[/eluser]
Can someone please tell me where to put the file jquery.js (or wich one is the file used?) in order to get the instruction:

$this->load->library('jquery');

And be able to used it?
#2

[eluser]Jamie Rumbelow[/eluser]
Well, a CodeIgniter Library is actually a PHP class, so your best bet is to make a helper file with a function in that $this->output->set_output() a <script> tag.
#3

[eluser]skyrocket777[/eluser]
you got me even more confused. Sorry but your explanation is poor and has nothing related with the library wiki's page
#4

[eluser]Jamie Rumbelow[/eluser]
Ok.

jquery.js is a JAVASCRIPT file. A codeigniter library is a PHP file.
#5

[eluser]AgentPhoenix[/eluser]
Easiest thing to do now since there isn't a Javascript helper (like there will be in the next version of CI), is to put all your Javascript files at the root in a js folder or something. Then you can call the Javascript files from your views.
#6

[eluser]Lukifer[/eluser]
You can also let Google host jQuery for you. Put the following in your HTML head:
Code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
#7

[eluser]Chris Newton[/eluser]
I know what you're talking about. You're referencing the jquery library on the wiki, here: http://codeigniter.com/wiki/jQuery/ & the library is here: http://www.creatieve-cursussen.nl/jquery.phps

The library simply references it like this var $externalJquery='jquery.js'; That will probably not work depending on your controller setup. I'd suggest changing the location in teh library to something like:

Code:
var $externalJquery='/scripts/jquery.js';

or if you're autoloading the URL helper, you could do this:
Code:
var $externalJquery=base_url().'scripts/jquery.js';


so that you'd always be targeting relative to your CI application's root (not the web root)
#8

[eluser]Chris Newton[/eluser]
Actually, looks like you can just set it like this:

Code:
$this->load->library(’jquery’);
$this->jquery->setExternalJquery(URL_TO_YOUR_JQUERY);


But there's no harm in changing the default url in the library either. It'll save you a lot of repetitive typing if you're using the library often in your script.
#9

[eluser]Derek Jones[/eluser]
Quote:you got me even more confused. Sorry but your explanation is poor and has nothing related with the library wiki’s page

::glances at the the "Start a discussion about this article!" links in the wiki::




Theme © iAndrew 2016 - Forum software by © MyBB