Setting the value (selected option) of a dijit.form.Select widget

前端 未结 3 1994
刺人心
刺人心 2020-12-31 07:16

I have a dijit.form.Select widget. It\'s tied to a data store, if that matters. It\'s filled with several options already. All I want to do is programmatically set its value

相关标签:
3条回答
  • 2020-12-31 07:43

    Repost of my comment: There is a test page here: dojo archive that you can mess with. Using fire-bug I used dijit.byId('s9').attr('value', 'CO') successfully on that page. That will set the "store-based" Select on that page.

    But as you said I set it using a string and you were using integers so I didn't see the bug. Good catch.

    0 讨论(0)
  • 2020-12-31 08:04

    Turns out it's a bug - if the option values aren't strings, it won't work (mine were integers).

    0 讨论(0)
  • 2020-12-31 08:05

    Even if your values are ints, if you set your integer to a string then this will work.

    dijit.byId( 'my_select' ).attr( 'value', String( 5 ) );
    
    0 讨论(0)
提交回复
热议问题