data-dojo-attach-point

In Dojo declaration and Dojo template, we often see statements like dojoAttachPoint=”xxx”. After checking the documents, I finally got some rational understanding. An example is as follows: If you want to modify thead and tr in js, you can use the alias head and headRow specified by dojoAttachPoint to refer to thead and tr so that you can operate it. A deeper understanding is that thead and tr respectively correspond to the DOM Node on the DOM tree of the page. When JS manipulates the DOM tree, it can only be operated when an instance of the DOM node is obtained. For example, in the above example table, when you want to add a td node, you must get the instance of tr, and then operate on it; the code implemented in JS is as follows: var tth = document.createElement(“th”); this. headRow.appendChild(tth); Or: this.headRow.appendChild(document.createElement(“td”)); In fact, it is no different from setting the id and then getting the dom node through byId, but this is just a little bit.

Leave a Comment

Your email address will not be published.