javascript - how to remove dom reference and event delegation to dom elements/fields from object properties -


if have object properties referencing dom element, , delegates events on widgets/ fields in dom, removing main wrapper dom element jquery mainobj.properties.elem.$html_main.empty().remove() removes events handler other object properties($form,$table,$tab), , need manually assign each one(properties references) null gc. if assign null main parent object, children of automatically eligible gc. if assign mainobj = null, child object, properties, properties.elem, properties.elem.$form.... etc null , collectible gc. there lingering dom links child objecta after nullifying mainobj.

my obj:

mainobj {      properties:{          elem:{              $form:'referencetodomform',              $table: 'referncetotableelement'              $tab: 'referencetodivelement',              ...               },          $html_main:'referencetomaindom',          otherprops:{ ...},          ...        }  }

if higher level object no longer reachable because nulled out variable reference , no other code has references of child objects, eligible garbage collection unreachable code though contain dom references.

fyi, in general, avoid storing dom references @ all, rather retrieve them dom query whenever needed @ start of function. avoids chance of leaking dom node because forgot null reference somewhere.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -