Welcome Guest, Not a member yet? Register   Sign In
use of javascript/jquery library
#1

[eluser]Unknown[/eluser]
I am new to codeigniter. I am not able to use javascript and jquery library in codeigniter.
i have searched alot on google and forums but could not get the answer.


tried this way..

controller
Code:
class jquery_demo extends CI_Controller
{
    function __construct()
   {
        parent::__construct();
       $this->load->library('javascript');  
    
   }

function index()
{
$this->javascript->click('#button', "alert('Hello!');");
$this->javascript->compile();
$data['library_src'] = $this->load->get_var('library_src');
$data['script_head'] = $this->load->get_var('script_foot');
$this->load->view('js_test',$data);
}
}

view..

Code:
<!DOCTYPE html>
&lt;html&gt;
    &lt;head&gt;
        &lt;?php echo $library_src;?&gt;
&lt;?php echo $script_head;?&gt;
        [removed]
            
        
            [removed]
          
        &lt;title&gt;Jquery test&lt;/title&gt;&lt;/head>
    &lt;body&gt;
        &lt;?php
        echo form_open();
echo form_button("button","button","id='button'");
echo form_close();

?&gt;
    &lt;/body&gt;
&lt;/html&gt;


but no action is performed by clicking on button....
can anyone give me a solution please...Sad
#2

[eluser]Unknown[/eluser]
I think It's a good way to seperate the php and the javascript.
it means that you can just include the jquery source file in the template html files, and code just pure javascript code.




Theme © iAndrew 2016 - Forum software by © MyBB