Thursday, 18 December 2014

Ajax Submit Button, Prevent multiple posts in YII

Yii::ajaxsubmitbutton – Prevent multiple post
To prevent the ajaxsubmitbutton from doing multiple post, add the ‘beforeSend’ option to your code:
<?php echo CHtml::ajaxSubmitButton(‘Save’,
                                   array(‘formWorkHoursDays’),
                                   array(
                                                      ‘success’=>’function(html) { alert(html); }’,
                                                      ‘beforeSend’=>’function(){
                                                                        $(\’body\’).undelegate(\’#submitMe\’, \’click\’);
                                                                    }’,    

                                                        ),
                                    array(‘id’=>’submitMe’, ‘name’=>’submitMe’, ‘class’=>’submitButton’)
                              );
?>

No comments:

Post a Comment