Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
73
rated 0 times [  78] [ 5]  / answers: 1 / hits: 30491  / 14 Years ago, sat, february 19, 2011, 12:00:00

As title said, I'm trying to figure out how to use javascript and jquery libraries on CI.



Following instruction in the docs, I load the library in my controller:



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


Then, I define the location of the jQuery file (jquery.min.js) in the config.php:



$config['javascript_location'] = 'http://localhost/ci/assets/js/jquery/');


After that, I open the view file and put in these two lines:



<?php echo $library_src;?>
<?php echo $script_head;?>


First error comes up here: Undefined variable $library_src and $script_head (don't understand where I have to set them)



Anyway, I've commented these lines and continue with jquery lib, by loading it in my controller with:



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


Next error: Unable to load the requested class: jquery. (it seems that it can't find the lib, what i messed up?)



Checking on system folder it looks all files are in place:



system/libraries/Javascript.php
system/libraries/javascript/Jquery.php


Thanks in advance for your help!


More From » php

 Answers
30

It is important to note that this Driver is marked as experimental so I wouldn't rely on it.



Also, personally I think it's asking for confusion and headaches to try and directly mix server-side portions of your applications with client side portions.



To use javascript in your views, I would just start out by loading them like this...



<script type=text/javascript src=<?= base_url() ?>path/to/jquery.js></script>

[#93668] Thursday, February 17, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
emanir

Total Points: 151
Total Questions: 90
Total Answers: 105

Location: Suriname
Member since Sun, Jun 13, 2021
3 Years ago
;