Attach-point vs placeAt in Custom Widget

914
1
Jump to solution
01-20-2019 09:46 PM
PrashantKirpan
Occasional Contributor

Hi All,

I was exploring add data widget code and I can see two different ways to attach DOM element while instantiating custom widgets.

To instantiate "AddFromFilePane" widget below code is used. this.fileNode is actually data-dojo-attach-point="fileNode" in template.

this.addFromFilePane = new AddFromFilePane({
wabWidget: this
},this.fileNode);

and for "LayerListPane",placeAt function is used to assign domNode.

 

this.layerListPane = new LayerListPane({
wabWidget: this
});
this.layerListPane.placeAt(this.domNode);
}

I got some idea about placeAt() on dojo/dijit custom widget document but didn't find any help for first scenario.

Just wanted to know main difference between these two implementation and any help document which explain first scenario in detail.

Any help would be appreciated,

Regards,

Prashant

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Prashant,

  This is something you will not find explicit help documentation on. PlaceAt (as you have already mentioned) is a dojo dijit/widget native method for adding the dijit to a particular dom node. Normally you use this when creating a dijit programatically and need to add it to the dom. Hardly ever do I use it as in my widget development I have a dom node that uses data-dojo-attach-point in my widget template that I will replace with the programatically created dijit. In the example you have above the programatically created dijit is placed at the parent widgets domNode which very likely does not have a data-dojo-attach-point that could be used.

View solution in original post

1 Reply
RobertScheitlin__GISP
MVP Emeritus

Prashant,

  This is something you will not find explicit help documentation on. PlaceAt (as you have already mentioned) is a dojo dijit/widget native method for adding the dijit to a particular dom node. Normally you use this when creating a dijit programatically and need to add it to the dom. Hardly ever do I use it as in my widget development I have a dom node that uses data-dojo-attach-point in my widget template that I will replace with the programatically created dijit. In the example you have above the programatically created dijit is placed at the parent widgets domNode which very likely does not have a data-dojo-attach-point that could be used.