|
Updates
Using Components you rarely deal with the DOM directly; use the following instance methods instead:
object can be either a component or an HTML string that yields a new component: // Create a new note:
this.insert('<div class="note">...</div>');
// Move first note to the end:
this.append(this.note);
// Remove all notes:
while (this.note)
this.note.remove();... where 'note' is a component type. Using these methods instead of insertBefore, removeChild etc keeps the object model intact, so that you can continue to use the properties and methods described previously. Content that you add, remove or use as an insertion point in the page should always be a component - they deserve their own place in the model! You can also update text in a component: this.update('Text to replace all existing content');
this.update({ foo: 'Replacement for contents of this.foo', bar: 'Replacement for contents of this.bar' });In the second form, you can only update controls that have text-only or no content (preventing you from wiping out content for other components, which is only possible in the first form). For changing class names, see Flags. |