#16025 closed task (invalid)
Templated form throws "target is null" exception unless attach point given : dijit/_TemplatedMixin, dijit/form/Form, dijit/Dialog, dijit/layout/ContentPane, on.js:42
Reported by: | bishop | Owned by: | bill |
---|---|---|---|
Priority: | undecided | Milestone: | tbd |
Component: | Dijit | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
Looks like a form created from a template needs to have an attach point in the template, while div created from template or form created with dom construction do not.
The example problem code goes like this:
new Dialog({content:new TemplateForm()}, 'container').show(); // where "TemplateForm" is like: define( [ 'dojo/_base/declare', 'dijit/_WidgetBase', 'dijit/_TemplatedMixin', 'dijit/form/Form' ], function ( declare, WidgetBase, TemplatedMixin, Form) { return declare([WidgetBase, TemplatedMixin, Form], { templateString:'<form><div><p>I am just a form (no attach point).</p></div></form>' }); } );
But neither a template with a div root node nor a form created with domConstruct.create('form', {innerHTML:'...'}); need an attach point.
I've scoured the docs and sitepen in case there was some exception with templated forms, including:
- http://dojotoolkit.org/reference-guide/1.8/quickstart/writingWidgets.html
- https://dojotoolkit.org/documentation/tutorials/1.6/templated/
- http://www.sitepen.com/blog/2011/08/25/how-do-i-create-a-dynamic-validating-internationalized-form-in-a-dialog/
but I can't find any. So, if form legitimately needs an attach point when templated then I think the docs need clarification. If form shouldn't need it, then some code needs tweaking (though not sure if it's template mixin or form).
Attached is some code evoking these paths.
Attachments (1)
Change History (6)
Changed 8 years ago by
Attachment: | scenario.zip added |
---|
comment:1 Changed 8 years ago by
Owner: | changed from bill to bishop |
---|---|
Status: | new → pending |
comment:2 Changed 8 years ago by
Status: | pending → new |
---|
Ok, whoops, PlainForm? did indeed need to extend Form ... which I did and yep it broke.
But the TemplateDiv? ones should not extend form, since I want them to be rooted on a <div> to illustrate my point: extending Form requires attach point, extending WidgetBase? does not, and this doesn't appear to be in the documentation.
Assuming attach point just is required for Form extensions, then I propose re-categorizing this ticket as into the documentation component.
comment:3 Changed 8 years ago by
Owner: | changed from bishop to bill |
---|---|
Status: | new → assigned |
Type: | defect → task |
there are many widgets that require certain attach points that need to be considered if you override their templates - and none of this is explicitly documented. it's been expected that developers can look at the template they are overriding and figure out what it provides to the widget and make sure that the new template is suitable.
i'm passing to bill to decide if this ticket needs to remain open. documenting all the attach points would take quite a big effort initially and could turn into a lot of maintenance so i'll leave it to him to decide if it's something he wants to do.
comment:4 Changed 8 years ago by
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
actually... this particular case is already covered by the API docs.
In templated widgets, "containerNode" is set via a data-dojo-attach-point assignment.
http://dojotoolkit.org/api/1.8/dijit/form/Form#containerNode
i'm closing out this ticket since the docs already address your issue.
comment:5 Changed 8 years ago by
Hmm, didn't see that. Thanks for the link.
I would only recommend changing the verbiage "is set via" to "must be set via".
you need to fix up your examples - they are not equal comparisons. once you fix them i think you'll find that they all need an attach point.
i haven't confirmed what i'm saying here but if you fix your example and there are problems then someone will take a look.