1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    8
    Vote Rating
    0
    Lukich is on a distinguished road

      0  

    Default Answered: Creating select element

    Answered: Creating select element


    Hello. I'm trying to create a select element which would get added to a panel when I click a button.

    After looking at the docs I tried this to create the select node itself:

    Code:
    var a = new Ext.Element('select');
    It does create an element. However, I'm now trying to add an id to it. It is my understanding that I use the set command, but when I try something like this:

    Code:
    a.set( { 'id' : 'test' } )
    I get an error saying "TypeError: Cannot read property 'setAttribute' of undefined".

    What am I missing?
    Thanks you!
    Luka

  2. Which version of ExtJS is this?

    new Ext.Element('select') will create a new instance of Ext.Element and attempt to associate it with the HTML DOM element that has the id 'select'. As this doesn't exist it will instead have undefined as its dom property and this will blow up as soon as you try to manipulate it.

    There are many, many ways to create a new HTML element in ExtJS. For a panel you'd usually use one of the methods on the panel to inject HTML. e.g. update().

    To get an Ext.Element wrapper around a new element you could use:

    Code:
    var a = Ext.get(document.createElement('select'));
    I would also suggest not trying to use a select element at all. Use an Ext ComboBox or MultiSelect.

  3. #2
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,338
    Answers
    498
    Vote Rating
    248
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      0  

    Default


    Which version of ExtJS is this?

    new Ext.Element('select') will create a new instance of Ext.Element and attempt to associate it with the HTML DOM element that has the id 'select'. As this doesn't exist it will instead have undefined as its dom property and this will blow up as soon as you try to manipulate it.

    There are many, many ways to create a new HTML element in ExtJS. For a panel you'd usually use one of the methods on the panel to inject HTML. e.g. update().

    To get an Ext.Element wrapper around a new element you could use:

    Code:
    var a = Ext.get(document.createElement('select'));
    I would also suggest not trying to use a select element at all. Use an Ext ComboBox or MultiSelect.

  4. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    8
    Vote Rating
    0
    Lukich is on a distinguished road

      0  

    Default


    Thank you, ComboBox worked great!

    Luka

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar