orionjs / orioncms

[Old] Orion is an open source framework built on Meteor that makes complex as well as simple apps possible with minimal effort.
http://orionjs.org
MIT License
715 stars 129 forks source link

RouterLayer.go prevents endSubmit event in AutoForm #411

Open singlow opened 8 years ago

singlow commented 8 years ago

When RouterLayer.go is called in the onSuccess hook in the materialize theme, it causes the current template to be destroyed. Because of this, the endSubmit hook does not execute. It checks the template before running and does not call the endSubmit hook if the template is destroyed or doesn't exist.

As a result, the Session variable that controls the disabled state of the submit buttons is never reset and the buttons remain disabled on forms.

Several possible solutions. A) don't use a session variable, so the state does not leak to other template instances. B) defer the router action so that the AutoForm hooks can complete before the template is destroyed. C) reset the Session variable on success before changing routes.

I think both A and B might be the best option. We should be using ReactiveVar for this, rather than session. And we also should allow the AutoForm endSubmit to run, even though the ReactiveVar approach would work fine even if endSubmit never executes.