Turns out that all my mixins aren't working after a zone update.
I am sure it's my fault somewhere, but I just can't figure out where.
Basically, if you put this mixin into a form that's inside the zone,
when the zone is refreshed, the mixin stops working.
It's not just this one, I have similar mixins that all stop working too just 
like this.

Full code is available at http://code.google.com/p/flowlogix

Thank you!

------------------ Java Mixin --------------------
@Import(library="DisableAfterSubmit.js")
public class DisableAfterSubmit
{
    @AfterRender
    void addDisabler()
    {
        JSONObject spec = new JSONObject();
        spec.put("elementId", submitButton.getClientId());
        spec.put("formId", fs.getClientId());
        js.addInitializerCall("disableAfterSubmit", spec);
    }
    
    
    @Environmental private JavaScriptSupport js;
    @InjectContainer private ClientElement submitButton;
    @Environmental private FormSupport fs;
}

-------------------- JavaScript ----------------------------
/**
 * Disable Submit button after AJAX Form Submission
 */

var DisableAfterSubmit = Class.create();
DisableAfterSubmit.prototype = {
    initialize: function(elementId, formId) {
        this.formId = formId;
        this.elementId = elementId;
        this.handler = this.doEnable.bindAsEventListener(this);

        Event.observe($(elementId), 'click',
            this.doDisable.bindAsEventListener(this));                  
    },

    doDisable: function() {
        $(this.elementId).disable();

        if($(this.formId).getStorage().zoneId != null) {
            this.zoneId = Tapestry.findZoneManager(this.formId).element;
            Event.observe($(this.zoneId), Tapestry.ZONE_UPDATED_EVENT, 
              this.handler);    

            $(this.formId).onsubmit();
        }
        else {
            $(this.formId).submit();
        }
    },
                
    doEnable: function() {
        $(this.zoneId).stopObserving(Tapestry.ZONE_UPDATED_EVENT, this.handler);
        var element = $(this.elementId);
        if(element != null) {            
            $(this.elementId).enable();
        }
    }
};


// Extend the Tapestry.Initializer with a static method that instantiates us
Tapestry.Initializer.disableAfterSubmit = function(spec) {
    new DisableAfterSubmit(spec.elementId, spec.formId);
};


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to