[eluser]j4zzyh4ck3r[/eluser]
[quote author="eokorie" date="1297828488"]Hi
Try this:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Javascript_test extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->library('javascript');
$this->load->library('jquery', FALSE);
}
function index() {
$data = array();
$this->jquery->script('/assets/js/jquery/jquery.js', TRUE);
$js = $this->javascript->hide('#myDiv');
$this->javascript->output($js);
$this->javascript->compile();
$this->load->view('index',$data);
}
}
Your html would the look like this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<title>Javascript Test</title>
<?php echo isset($script_head) ? $script_head : ''; ?>
</head>
<body>
<div id="myDiv">
This is my div!
</div>
<?php echo isset($library_src) ? $library_src : ''; ?>
<?php echo isset($script_foot) ? $script_foot : ''; ?>
</body>
</html>
Hope this helps![/quote]
That helps a lot, thanks bro,
but why the jQuery code generated two times like this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Javascript</title>
[removed][removed]
[removed][removed]
[removed]
// <![CDATA[
$(document).ready(function() {
$("div#my_div").click(function(){
$("div#my_div").hide(1000);
return false;
});
$("div#my_div").click(function(){
$("div#my_div").hide(1000);
return false;
});
});
// ]]>
[removed]
</head>
<body>
<div id="my_div"><h1>This is my div !</h1></div>
</body>
</html>