Can a form loaded by a widget be reused/cloned ?

5
I want to retrieve a form, put its contents into an htmlElement and subsequently reuse/clone it. I have: getForm : function(form, callback) { var element = dojo.create("div"), mxui.lib.putContent(form, {}, element) .addCallback(dojo.hitch(this, function() { callback.call(this, element); })); } And then later on I want to use it as such (pseudo): this.getForm(this.form, function(element) { var ctx, clonedElement; for(var i = 0; i < this.mxObjects.length, i++) { ctx = this.createContext(); ctx.setContext(mxObjects[i].getEntity(), mxObjects[i].getGUID()); clonedElement = dojo.clone(element); dojo.place(clonedElement, this.myContainer); formObject = clonedElement.childNodes[0].childNodes[0]; formObject.applyContext(ctx, function()); }); This does not seem to work, the cloned forms does get added to 'this.myContainer', but it seems like the context is not being applied. After some investigation I noticed that each form has a widgetid that should probably be unique for the page (and probably gets registered when calling putContent). Every cloned form has other child elements (depending on the form loaded) that should probably have unique id's. Anybody have a suggestion on how to load a form once and reuse it ? Also a link/documentation on mx.lib.putContent().
asked
1 answers
1

I'd upvote the answers, if only they weren't posted as comments! :)

Do note that cloning and moving forms can result in ... tricky situations regarding memory usage and the browser's garbage collector. I'd advise you to keep an eye on this while testing your new feature.

answered