#5775 closed defect (worksforme)
Broken Backwards compatibility for dijit.form.Form
Reported by: | nathan | Owned by: | Douglas Hays |
---|---|---|---|
Priority: | high | Milestone: | 1.1 |
Component: | Dijit - Form | Version: | 1.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
In the latest code from svn, it appears that dijit.form.Form's execute method is deprecated. That's fine, but if I want to use a dijit.form.Form as a subwidget of another widget, how can I tie in to the submit event?
What worked previously in a templateString: <form dojoType="dijit.form.Form" dojoAttachEvent="execute:_processForm">
I tried setting dojoAttachEvent="onSubmit:_myFunc" and dojoAttachEvent="submit:_myFunc" - but neither of them have a way of "cancelling" the event from firing (the form still gets submitted). Tying in to execute previously (in 1.0.2) would attach me when the form was submitted (by pressing <enter> or by clicking a submit button).
Maybe a good compromise would be to offer an option on dijit.form.Form - so that you can do something like this: <form dojoType="dijit.form.Form" dojoAttachEvent="onSubmit:_processForm" doSubmit="false">
doSubmit would default to true - but the onSubmit() function for dijit.form.Form would then return (this.isValid() && this.doSubmit) instead of just this.isValid()
Change History (8)
comment:1 Changed 14 years ago by
Cc: | [email protected]… removed |
---|---|
Component: | General → Dijit |
Milestone: | → 1.1 |
Owner: | changed from anonymous to Douglas Hays |
Reporter: | changed from guest to [email protected]… |
comment:2 Changed 14 years ago by
If you override, yes, it does cancel - but returning false from it when it's *connected* doesn't seem to...
comment:3 Changed 14 years ago by
Oh, right, that's the way connections work regardless of what function you are connecting to. The return value from a connection is ignored. You need to override the function.
I see how that's difficult when using Form as a subwidget in a template for another widget though. Hmm. I guess that's a general limitation of the widgetsInTemplate feature that should be addressed at some point.
One option is to declare your own widget. Note how Dialog doesn't extend Form, but rather just uses _FormMixin:
dojo.declare( "dijit.Dialog", [dijit.layout.ContentPane, dijit._Templated, dijit.form._FormMixin, dijit._DialogMixin],
Anyway, leaving open to discuss with Doug.
comment:4 Changed 14 years ago by
Doug just pointed out to me that you could just *add* onSubmit="return false;"
to your template, like:
<form dojoType="dijit.form.Form" onSubmit="return false;" dojoAttachEvent="execute:_processForm">
You could connect to onSubmit rather than execute (since execute() is deprecated) but the only problem is that onSubmit() isn't passed the form values, so you have to call this.getValues() inside of your function.
I guess this is a break in backwards compatibility from the perspective of widgetsInTemplate, but from the common use case of using a Form widget as an actual form on a page, it's more like a bug fix, so that's why we changed it for 1.1.
Does that work for you?
comment:5 Changed 14 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Confirmed with Nathan that this issue has been resolved.
comment:6 Changed 14 years ago by
Reporter: | changed from [email protected]… to nathan |
---|
comment:7 Changed 14 years ago by
I have fixed my forms , simulating the old execute method by
<form dojoType="dijit.form.Form" id="sequence_filtering"> {literal} <script type="dojo/method" event="onSubmit" args="evt"> dojo.stopEvent(evt); //do your processing
comment:8 Changed 11 years ago by
Component: | Dijit → Dijit - Form |
---|
Hmm, I thought the submit would be canceled just by returning false from that onSubmit override. Doug?