Saturday, 28 May 2011

Dojo: Widgets & innerHTML

Question:
Why we use cp.attr("href", fileName); instead of cp.attr("innerHTML", fileName); ? where cp is a widget of type ContentPane.

Answer (by Karl Bishop)
innerHTML should only be used on native DOM nodes.

A ContentPane is much more than a glorified <div> tag. CP supports updates through either the href attribute for new remote URL resources, and also the content attribute for adding in new HTML content directly. The CP has triggers for these attributes so that it knows to parse the results for widgets, resize the containers as needed, as well as properly clean up any existing widgets prior to replacing the content.

Comment by Ahmed Fadel:
 The final conclusion is to completely avoid using innerHTML attribute with Dojo widgets

No comments:

Post a Comment