Monday, August 22, 2011

Ajax button in YII

Jquery was already  integrated in Yii Framework, we dont need to link the jquery library on   Yii apps.

Example using ajax in yii. All we need to do is familiar  the  ajax tags and how it in jquery, because it work same way and tags same way in yii with there button, submit even  in link.

It is format this way. ie. ajax button.

Chtml - form tag of yii
ajaxButton - ajax button tag

Chtml::ajaxButton (
        'Button Label',   - //Label on the button
        ' array('URL')',   - // this the url of the proccess file... or use call the action function of the current controller.
       ' type' => 'post'  - // method type Post or GET
        'data' =>array(), - // Data you want to send to copntroller.. must be in array
        'success' => 'function(data) { ---Do somthing here-- }',

Tips: You can remove the data array if you working with a form.

1 comment:

  1. thanks for your tutorial,it will be nice if you added a real case for sending data to controller like an id,otherwise its the same as the Yii-guide