php - How are ajax options supposed to be added to a UActiveForm? -


i've looked in framework documentation , yii forums, can't seem find on this. trying add ajax options uactiveform widget. put way, want loading gif inserted div when submit button of ajax form clicked. know how in raw javascript/jquery/php, can't seem done framework. here begin widget code:

<?php $form=$this->beginwidget('uactiveform', array(     'id'=>'login-form',     'enableajaxvalidation'=>true,     'clientoptions'=>array(         'validateonsubmit'=>true,         'validateonchange'=>false,         'validateontype'=>false,     ),     'htmloptions' => array(         'enctype'=>'multipart/form-data','class'=>'white-popup-block'),     ), )); ?>  <!--form labels/inputs here-->  <?php $this->endwidget(); ?> 

below part of ajax code looks if without framework:

request = $.ajax({     url: "usersystem/login.php",     type: "post",     data: serializeddata,     beforesend: function() {         $('#loader').show();         $('button').off(); //unbind buttons     },     complete: function(){         $('#loader').hide();     },     success: function(data) {         $('#test').append(data);     } }); 

what want in particular beforesend , complete ajax options. have tried adding

'ajax'=> array(     'beforesend'=> 'function() {         alert("testing, ready");     }',     'complete'=> 'function(){         alert("testing,done");     }', ), 

to uactiveform widget options, doesn't work. appreciate in trying understand framework.

i don't know uactiveform is, assuming it's kind of cactiveform there beforevalidate , aftervalidate options can use part of clientoptions:

'clientoptions'=>array(     'beforevalidate' => new cjavascriptexpression('function() { ... })'),     'aftervalidate' => new cjavascriptexpression('function() { ... })'),     'validateonsubmit'=>true,     'validateonchange'=>false,     'validateontype'=>false, ), 

you need wrap function code inside cjavascriptexpression because otherwise yii treat string , json_encode it.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -