This project is archived and is in readonly mode.

#219 ✓resolved
elado

Form.Request - on failure doesn't fire onComplete like regular Request

Reported by elado | December 19th, 2009 @ 11:50 PM

this.request = new Request.HTML($merge({
        url: this.element.get('action'),
        update: this.update,
        emulation: false,
        spinnerTarget: this.element,
        method: this.element.get('method') || 'post'
}, this.options.requestOptions)).addEvents({
    success: function(text, xml){
        ['success', 'complete'].each(function(evt){
            this.fireEvent(evt, [this.update, text, xml]);
        }, this);
    }.bind(this),
    failure: function(xhr){
        this.fireEvent('failure', xhr);
    }.bind(this),
    exception: function(){
        this.fireEvent('failure', xhr);
    }.bind(this),
    complete: function(){
        this.fireEvent('complete');
    }.bind(this)
});

Should also have:

complete: function(){
    this.fireEvent('complete');
}.bind(this)

As Form.Request is a wrapper for a Request and not inherits it, its onComplete events aren't fired when the request just completes. They are need to be wired manually.

Comments and changes to this ticket

  • elado

    elado December 19th, 2009 @ 11:52 PM

    The original pasted code has the extra code by mistake, it should be:

    
    this.request = new Request.HTML($merge({
            url: this.element.get('action'),
            update: this.update,
            emulation: false,
            spinnerTarget: this.element,
            method: this.element.get('method') || 'post'
    }, this.options.requestOptions)).addEvents({
        success: function(text, xml){
            ['success', 'complete'].each(function(evt){
                this.fireEvent(evt, [this.update, text, xml]);
            }, this);
        }.bind(this),
        failure: function(xhr){
            this.fireEvent('failure', xhr);
        }.bind(this),
        exception: function(){
            this.fireEvent('failure', xhr);
        }.bind(this)
    });
    
  • elado

    elado December 20th, 2009 @ 12:02 AM

    Ok, one more fix. As request's onSucess fires its own onComplete, having another complete:function will fire them both. So need to move the fire to the failure event.

        failure: function(xhr){
            this.fireEvent('comeplete').fireEvent('failure', xhr);
        }.bind(this),
    
  • Scott Kyle

    Scott Kyle January 12th, 2010 @ 06:12 AM

    • State changed from “new” to “resolved”
    • Assigned user changed from “Aaron Newton” to “Scott Kyle”

    Fixed, thanks!

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The MooTools Extensions

People watching this ticket

Pages