Yii Framework Forum: jQuery deferred for forms validation. - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

jQuery deferred for forms validation.

#1 User is offline   alex-w 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 223
  • Joined: 25-November 10

Posted 19 January 2012 - 04:49 AM

If you want to use forms validation but send the data in your own ajax request it gets a bit tricky (Unless i'm doing it wrong :P )

Handy if you could fire validation manually and use the done/fail callbacks.

Something like,
$('#myform').yiiactiveform('validate')
.done(function() {

}).fail(function() {

});

1

#2 User is offline   alex-w 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 223
  • Joined: 25-November 10

Posted 08 October 2012 - 07:24 AM

Refresh,

...
$.fn.yiiactiveform.validate = function(form) {
  var $form = $(form), $form.data('settings'), validation = [];
  
  //Build an array of deferred validation functions.

  return $.when.apply(this, validation).fail(function() {
    //Update summary
  });
}
...


The developer can then use the function manually.
$.fn.yiiactiveform.validate(myform).done(function() {
  //All is good
});

0

#3 User is offline   yJeroen 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 94
  • Joined: 06-September 11
  • Location:The Netherlands

Posted 10 October 2012 - 03:01 AM

What exactly are you trying to do?

An ajax validation? And do X when it succeeds and Y when it fails?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users