Created
January 29, 2014 13:32
-
-
Save fragoulis/8688031 to your computer and use it in GitHub Desktop.
Yii CActiveForm Ajax Submit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
var yiiActiveFormAjax={ | |
beforeSend: function() { | |
var submit=$(this).find(':submit'); | |
submit.prop('disabled',true); | |
}, | |
complete: function(){ | |
var submit=$(this).find(':submit'); | |
submit.prop('disabled',false); | |
} | |
}; | |
$('form').data('settings').afterValidate=function(form, data, hasError){ | |
if(hasError) | |
return; | |
var $form=$(form); | |
var options=$.extend({}, yiiActiveFormAjax, { | |
type: $form.attr('method'), | |
url: $form.attr('action'), | |
data: $form.serialize(), | |
context: $form, | |
}); | |
$.ajax(options); | |
} | |
})(window.jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Two things need to be established: