-
19 Apr 2011 4:16 AM #1
Best practice for constructing new element from html snippet and Ext elements
Best practice for constructing new element from html snippet and Ext elements
My question is:
What is the best practice for constructing new element from html snippet and Ext elements?
Lets say I have html snippet in string variable, like this:
And in javascript I want to create two elements:HTML Code:<div class="root"> <div class="item"/> <div class="form"/> </div>
Then combine with html - put each element into appropriate div.Code:var extItem = new Ext.Panel(...) var extForm = new Ext.FormPanel(...)
And then put the created html fragment to Document:Code:var root = DomHelper.createDom({tag : 'div'}); DomHelper.insertHtml('beforeEnd', root, htmlSnippet); DomHelper.append(DomQuery.selectNode(".item", root), extItem); DomHelper.append(DomQuery.selectNode(".form", root), extForm);
Last command throws this exception (ExtJS version is 3.3.1):Code:DomHelper.append(DomQuery.selectNode("#inRealDocument"), root);
uncaught exception: [Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIDOM3Document.domConfig]" nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame :: http://localhost:8080/ext-3.3.1/ext-all-debug.js :: createHtml :: line 373" data: no]
What am I doing wrong?
Or, if you think this approach is not good, then - what would you suggest?Last edited by sorrro; 19 Apr 2011 at 5:26 AM. Reason: Added note
-
20 Apr 2011 3:24 AM #2
I would appreciate any ideas or suggestions on this.
I'm new to javascript, and I'm not sure whether this situation is usual or not.
Is it a correct way to build UI by combining html snippet and Ext widgets this way?
-
20 Apr 2011 5:07 AM #3
This is strictly a personal opinion, but if you're new to Javascript and ExtJs, I strongly recommend that you do everything using ExtJs objects.
Similar Threads
-
Issue adding buttons to HTML snippet
By Jangla in forum Ext 3.x: Help & DiscussionReplies: 10Last Post: 17 Mar 2010, 4:44 AM -
(newbiew) [TabPanel] How to add a new tab containing an HTML snippet
By ittayd in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 2 Jul 2009, 2:39 AM -
converting html snippet to ExtJS styled combobox
By Mango_lier in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 18 Feb 2009, 7:24 AM -
Put HTML snippet in Ext.form.FormPanel?
By Westside in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 24 Sep 2008, 11:10 PM -
Constructing Elements in HTTP vs new DOM nodes vs PHP??
By snoodle in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 10 Apr 2008, 8:53 AM


Reply With Quote