Pages

Showing posts with label jshelper. Show all posts
Showing posts with label jshelper. Show all posts

Sunday, June 9, 2013

Cakephp-Send Multiple elements in ajax request frpm ajaxhelper/jshelper

From the following post

http://itfeast.blogspot.in/2013/06/cakephp-20-create-0bserve-field.html

To send multiple elements in ajax request from ajaxhelper/jshelper

 'data'=>$(\'#category,#sort\');  

For example this is how I passed the same in cakephp
  <script type="text/javascript">  
            <?php   
              echo $this->Js->get('#category')->event('change',$this->Js->request(  
                  array('controller' => 'contributors', 'action' => 'changevideos'),  
                  array('update'=>'#vediocontainer','async' => true,'dataExpression' => true,'method' => 'post','data'=>'$(\'#category,#sort,#fileid\').serializeArray()')  
                  ),false);  
             ?>  

Cakephp 2.0-Create 0bserve field equivalent with new jshelper

Many things have changed in v2.0 of cakephp removal of ajaxhelper is one of them in its plce we have a new helper called jshelper() to perform similar tasks here is how to use observe field with jshelper in cakephp 2.x


 <?php  
 echo $this->Js->get('#category')->event->('change',$this->JS->request(array(  
 'controller'=>'contributers',  
 'action'=>'changevideos'),  
 array(  
 'update'=>'#videocontainer',  
 'async'=>true,  
 'dataExpression'=>true,  
 'method'=>Post,  
 'data'=>$(this).serialize()'),  
 false))  
 ?>   

Where #category is the id of element which fires event and #videocontainer is the id of div which is updated of data from controller "contributors" and its action "changevideos"