raptorjs-legacy / raptorjs

Source code for the RaptorJS Toolkit
Other
94 stars 12 forks source link

Detached widget loses references to DOM element #31

Closed philidem closed 11 years ago

philidem commented 11 years ago

Currently, when you remove a widget from the DOM it loses its reference to the root DOM element and I think this might confuse people.

I propose these changes: 1) Add "detach" method that saves a reference to DOM element and then removes DOM element from parentNode

this.el = this.getEl(); this.el.parentNode.removeChild(this.el);

2) Modify getEl() to return: this.el || document.getElementById(this.getElId(widgetElId))

3) Add various methods for reattaching widget to DOM (similar to methods in RenderResult). e.g. replaceChildrenOf, insertBefore, insertAfter, prependTo, appendTo

philidem commented 11 years ago

Made change so that widgets automatically store reference to DOM element in "el" property (if the widget has a root DOM element)