Welcome Guest, Not a member yet? Register   Sign In
jquery script
#1

[eluser]j4zzyh4ck3r[/eluser]
I have this code
Code:
class Javascript extends CI_Controller {
        private $_data;

        public function  __construct() {
            parent::__construct();
            $this->load->helper(array('url'));
            $this->load->library(array('javascript'));
            // $this->load->library(array('javascript', array(
            //     'js_library_driver'  => 'scripto',
            //     'autoload'           => FALSE
            // )));
            $this->jquery->script(base_url() . 'assets/libraries/jquery/jquery-1.5.2.min.js', TRUE);
            $this->javascript->output(
                $this->javascript->ready(
                    $this->javascript->click('#my-div',
                        $this->javascript->hide('#my-div', 1000)
                    )
                )
            );
            $this->javascript->compile();
        }

        public function index() {
            $this->load->view('javascript_view');
        }
    }

Why in the view source is like this...
Code:
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
        &lt;title&gt;::[removed]:&lt;/title&gt;        
        [removed][removed]
[removed][removed]
        [removed]
// &lt;![CDATA[
$(document).ready(function() {

    $("#my-div").click(function(){
        $("#my-div").hide(1000);
        return false;
    });

    $("#my-div").click(function(){
        $("#my-div").hide(1000);
        return false;
    });
    
});
// ]]>
[removed]
    &lt;/head&gt;
    &lt;body&gt;
        <div id="my-div"><h1>Hello World</h1></div>
    &lt;/body&gt;    
&lt;/html&gt;

The script call twice, it happens when I added jquery event...




Theme © iAndrew 2016 - Forum software by © MyBB