1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    218
    Vote Rating
    0
    humpdi is on a distinguished road

      0  

    Default how to create element in dom

    how to create element in dom


    hey guys!

    how can i create a element in dom like document.createElement('div'); ?

    ive read the Ext.Element documentation, but i cant figure out how the correct syntax is..
    please help me

    thanks

  2. #2
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Virginia, USA
    Posts
    220
    Vote Rating
    0
    dfenwick will become famous soon enough

      0  

    Default


    There are multiple ways, but I usually use the DomHelper class to do so:

    Code:
    Ext.DomHelper.append('parent-div', {tag: 'div', cls: 'new-div-cls', id: 'new-div-id'});

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    218
    Vote Rating
    0
    humpdi is on a distinguished road

      0  

    Default


    thank you for your quick response, but iam looking for the method to create an element directly, like document.createElement, after that i want to append it somewhere..

    thank you although

  4. #4
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Virginia, USA
    Posts
    220
    Vote Rating
    0
    dfenwick will become famous soon enough

      0  

    Default


    Ah, same way you'd create it with document.createElement:

    Code:
    myEl = new Ext.Element(document.createElement('div'));
    Later on you can put it wherever you want with Ext.Get('par-div').appendChild(myEl.dom)

  5. #5
    Ext User
    Join Date
    Mar 2007
    Posts
    218
    Vote Rating
    0
    humpdi is on a distinguished road

      0  

    Default


    thanks

  6. #6
    Sencha Developer
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    482
    Vote Rating
    1
    Wolfgang is on a distinguished road

      0  

    Default


    Given:
    myEl = new Ext.Element(document.createElement('div'));
    Ext.Get('par-div').appendChild(myEl.dom)
    Is there also a way to use the ext object like this?
    Ext.Get('par-div').appendChild(myEl)

  7. #7
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    Yes. appendChild works with Elements, strings, HTMLElements.

  8. #8
    Sencha Developer
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    482
    Vote Rating
    1
    Wolfgang is on a distinguished road

      0  

    Default


    Thanks.

Similar Threads

  1. create entire UI without ids?
    By em_te in forum Ext 1.x: Help & Discussion
    Replies: 16
    Last Post: 28 Mar 2007, 10:47 AM
  2. How to create new window pop look using dialog
    By gkassyou in forum Ext 1.x: Help & Discussion
    Replies: 16
    Last Post: 23 Mar 2007, 7:39 PM
  3. how to create a button use an image
    By joshokn in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 22 Mar 2007, 9:22 AM
  4. Ext.ContentPanel - create inactive
    By andrey.korolyov in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 16 Mar 2007, 5:49 PM
  5. DomHelper: cannot create a label tag
    By e.e.coli in forum Ext 1.x: Bugs
    Replies: 6
    Last Post: 30 Oct 2006, 12:16 PM

Thread Participants: 3