-
6 Aug 2012 7:47 AM #1
Answered: How To Create a SPAN tag without a DIV?
Answered: How To Create a SPAN tag without a DIV?
Hello,
I am using the DomHelper to generate some HTML, but everything is getting wrapped in a DIV tag. I would like my parent tag to be a DIV (which it is) but I want the child tags to be SPAN tags only. It seems that ExtJS wraps everything in DIVs, even plain HTML.
Thanks.
-
Best Answer Posted by evant
-
6 Aug 2012 10:38 AM #2
Try something like this:
Code:Ext.DomHelper.append(Ext.getBody(), { tag: 'div', children: [{ tag: 'span 1', html: 'Span 1' },{ tag: 'span 2', html: 'Span 2' },{ tag: 'span 3', html: 'Span 3' }] })
-
6 Aug 2012 12:27 PM #3
Using your example, having a parent <div> tag is fine. But each of the children <span> tags will be wrapped in yet another <div> tag. That's just unnecessary overhead in my opinion.
-
6 Aug 2012 12:33 PM #4Sencha - Community Support Team
- Join Date
- Nov 2007
- Location
- Helsingborg, Sweden
- Posts
- 2,494
- Vote Rating
- 57
- Answers
- 30
No, each span is not wrapped in any div. Try running this in Firebug.
Code:<div> <span 1="">Span 1</span> <span 2="">Span 2</span> <span 3="">Span 3</span> </div>
-
6 Aug 2012 12:43 PM #5
Ok then the problem I am facing is that the children are actually Ext components. It's the fact that's it's a component that creates that outer <div> wrapper. I wanted some class-level functionality for my <span> tags, to treat them as individual objects. But extending Ext.Container wraps them in <div> tags.
Thanks.
-
6 Aug 2012 1:24 PM #6
How can I make those Ext.Component <div> tags be display:inline instead of display:block?
-
6 Aug 2012 1:42 PM #7Sencha - Ext JS Dev Team
- Join Date
- Apr 2007
- Location
- Sydney, Australia
- Posts
- 15,242
- Vote Rating
- 106
- Answers
- 187
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
6 Aug 2012 2:41 PM #8
@ evan... this looks exactly like what I need. Thanks!


Reply With Quote