correct but I would change the steps a little: * Step 3: RemoveAllChildren on the template * Step 5: Re-add those widgets that are needed, destroy the rest * Step 6: setHTML on the template with the new HTML
Otherwise you would have to call generate() for after you've added the new widgets after you've set the html of the template. When setHTML() is called it calls the generate() function to display the template's fields, etc so it would be best to add those widgets before setHTML is called. It's always good to know the name of the fields before hand. P.S. Maybe we can do something like clearTemplate(method) tp.clearTemplate('destroy') tp.clearTemplate('remove') tp.clearTemplate('reuse') -- Raymond Irving --- Jacob Levy <[EMAIL PROTECTED]> wrote: > Sorry, my feature request was not well thought-out. > By the time you let > the template parse the HTML it's going to already > need the widgets. Better > to do what I think you're implying: > > * Step 1: create the template with an HTML string or > setHTML on an > existing template > * Step 2: create your widgets and add them both to > an array and to the > template. > * ... > * Step 3: RemoveAllChildren on the template > * Step 4: setHTML on the template with the new HTML > * Step 5: discover which widgets are still needed > with getFieldNames > * Step 6: Re-add those widgets that are needed, > destroy the rest > > That seems water-tight as far as memory mgmt goes, > right? > > --JYL > > > --- Jacob Levy <[EMAIL PROTECTED]> wrote: > >> Is there a way to find out what named javascript > >> objects a template will > >> need? > > > > I think such a feature would be useful. I think I > can > > add something like getFieldNames(). > > > >> Itd be nice to keep those around (rather than > >> having to recreate > >> them) if the template changed in a way that > simply > >> moved some of the > >> existing elements to new locations. > > > > IMO you can create the objects, store them in an > array > > then use removeAllChildren() to remove them from > the > > template before you change the template with > > setHTML(). When they're need you can then add them > to > > the template. > > > > -- > > Raymond Irving > >> With such an API I can write a loop that destroys > >> those children that will > >> no longer be needed. > >> > >> --JYL > >> > >> > --- Jacob Levy <[EMAIL PROTECTED]> wrote: > >> > > >> >> Is it possible to update the template after > its > >> set? > >> > > >> > Yes > >> > > >> >> That is, let's say I > >> >> get another template from the server and then > do > >> >> tmpl.setHTML(newHTML), > >> >> will that update the layout to the new > template? > >> Any > >> >> other requirements so > >> >> as not to leak memory (like destroying > something > >> >> before calling setHTML > >> >> again)? > >> > > >> > Once you call setHTML() it will replace content > of > >> the > >> > Template those removeing the elements of the > >> > DynLayers, etc. For best use call > clearTemplate() > >> to > >> > deleteAllChildren from the template before > >> changing > >> > the content. this will prevent memory leaks. > >> > > >> >> > >> >> Thanks! --JYL > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> > > >> > > > ------------------------------------------------------- > >> >> This sf.net email is sponsored by:ThinkGeek > >> >> Welcome to geek heaven. > >> >> http://thinkgeek.com/sf > >> >> > _______________________________________________ > >> >> Dynapi-Dev mailing list > >> >> [EMAIL PROTECTED] > >> >> > >> > > >> > > > http://www.mail-archive.com/[EMAIL PROTECTED]/ > >> > > >> > > >> > __________________________________ > >> > Do you Yahoo!? > >> > Yahoo! SiteBuilder - Free, easy-to-use web site > >> design software > >> > http://sitebuilder.yahoo.com > >> > > >> > > >> > > >> > > > ------------------------------------------------------- > >> > This sf.net email is sponsored by:ThinkGeek > >> > Welcome to geek heaven. > >> > http://thinkgeek.com/sf > >> > _______________________________________________ > >> > Dynapi-Dev mailing list > >> > [EMAIL PROTECTED] > >> > > >> > > > http://www.mail-archive.com/[EMAIL PROTECTED]/ > >> > >> > >> > >> > >> > >> > > > ------------------------------------------------------- > >> This sf.net email is sponsored by:ThinkGeek > >> Welcome to geek heaven. > >> http://thinkgeek.com/sf > >> _______________________________________________ > >> Dynapi-Dev mailing list > >> [EMAIL PROTECTED] > >> > > > http://www.mail-archive.com/[EMAIL PROTECTED]/ > > > > > > __________________________________ > > Do you Yahoo!? > > Yahoo! SiteBuilder - Free, easy-to-use web site > design software > > http://sitebuilder.yahoo.com > > > > > > > ------------------------------------------------------- > > This sf.net email is sponsored by:ThinkGeek > > Welcome to geek heaven. > > http://thinkgeek.com/sf > > _______________________________________________ > > Dynapi-Dev mailing list > > [EMAIL PROTECTED] > > > http://www.mail-archive.com/[EMAIL PROTECTED]/ > > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dynapi-Dev mailing list > [EMAIL PROTECTED] > http://www.mail-archive.com/[EMAIL PROTECTED]/ __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Dynapi-Dev mailing list [EMAIL PROTECTED] http://www.mail-archive.com/[EMAIL PROTECTED]/