load->library('jquery'); $this->jquery->setExternalJquery('jquery.js'); $this->jquery->addExternalScript('jquery.tablesorter.js'); //load jQuery plugin $this->jquery->setJqDocumentReady(true); //add $(document).ready(){ } stuff, saves a line of code to write $this->jquery->addJqueryScript('$("p").eq(1).after("

You can see that the link in the next paragraph is wrong. Click here to fix it Clicking will start an AJAX request to another file which will output some script that will alter the link. It\'ll also show you what Jquery is about.

"); '); //manually add jQuery stuff setJqueryScript() replaces, addJqueryScript appends $this->jquery->addJqueryScript('$("p.wronglink").css("background","red").css("color","white");'); $vars=array('id'=>1,'CodeIgniter'=>'CodeIgniter rocks','jQuery'=>'jQuery is awesome'); //will be passed in the ajax request $this->jquery->JqueryObject('ajaxcall','ajax'); //new object of type ajax $this->jquery->ajaxcall->setRequestUrl('http://www.creatieve-cursussen.nl/test/output_ajax'); $this->jquery->ajaxcall->setDataType('script'); //says that the page will output javascript (could be 'html','xml' or 'json' check jquery api) $this->jquery->ajaxcall->setData($vars);// what will be passed // $this->jquery->ajaxcall->setDataRaw('html=fancy'); //setDataRaw is also possible, use GET/POST syntax $this->jquery->ajaxcall->setRequestType('POST'); //$this->jquery->weird->getJqAjaxCall(); $ajax=$this->jquery->getJqueryObject('ajaxcall'); //$this->jquery->addJqueryScript(); $this->jquery->JqueryObject('pclick','event'); //new object of type event $this->jquery->pclick->assignEventTo("a.wronglink"); //attach to a.wronglink $this->jquery->pclick->assignJavascript('function(){ '.$ajax.' }'); $this->jquery->pclick->assignType('bind'); //bind it $this->jquery->pclick->assignEvent('click');//trigger event on click $this->jquery->addJqueryObject('pclick'); //back to original class $template['js']=$this->jquery->processJquery(); $this->load->view('test_view',$template); } function output_ajax(){ $this->load->library('jquery'); $this->jquery->JqueryObject('replace','assign'); //initiate new object of type 'assign' with name replace $this->jquery->replace->assignValue('http://www.codeigniter.com/user_guide/');//value to be added $this->jquery->replace->assignValueTo('a');//value is added to all A in the DOM $this->jquery->replace->assignLocation('href');//value is added to href attribute $this->jquery->addJqueryObject('replace'); //add the object to the script $this->jquery->addJqueryScript('$("p.wronglink").empty().after("

Yeah, you fixed it by some leet AJAX. Next to that you added some of the variables passed to the ajaxpage to this page. What it says is true :) ci@kinderpartijtjes.net for email (spam bots won\'t see the email because of the ajax :) )

");'); $this->jquery->addJqueryScript('$("p.wronglink").css("background","red").css("color","white");'); $jquerytext="

jQuery is a new type of JavaScript library. It is not a huge, bloated framework promising the best in AJAX - nor is it just a set of needlessly complex enhancements - jQuery is designed to change the way that you write JavaScript.

Notice the red, white and blue, colours of my national flag in the right order :)

"; $newP=$this->input->post('jQuery').'
'.$this->input->post('CodeIgniter'); $this->jquery->JqueryObject('newp','assign'); //initiate new object of type 'assign' with name replace $this->jquery->newp->assignValue($newP .$jquerytext);//value to be added $this->jquery->newp->assignValueTo('#ajaxc');//value is added to the element with the id ajaxc attached to it $this->jquery->newp->assignLocation('prepend');//value is added to prepended in the element $this->jquery->addJqueryObject('newp'); //add the object to the script $this->jquery->addJqueryScript('$("p.jquerytext").css("background","blue").css("color","white");'); $this->jquery->addJqueryScript('$(".jquerytext a").css("background","white").css("color","blue");'); $this->jquery->printJqueryScript(); // output the script (without all the