3

I've installed the 1.10 version of jQuery and I am getting this error when trying to set the value as the way I've always done so with the selectmenu widget.

Error: Uncaught Error: no such method 'value' for selectmenu widget instance

$('select.widthOpts').selectmenu('value', wDims.feet);

I also receive the same error when attempting to set the index of the selectmenu.

Aesthete
  • 18,622
  • 6
  • 36
  • 45

2 Answers2

11

the below code also works fine. I am using jQuery 1.10.2 and jquery-ui 1.11.1

$('select.widthOpts').val(wDims.feet).selectmenu('refresh')
user3034740
  • 121
  • 2
  • 6
4

Are you aware there are two versions?

https://github.com/fnagel/jquery-ui/ (old, fork of filament groups work) https://github.com/jquery/jquery-ui/tree/selectmenu (new, official)

The new one does not have value or index methods.

Since you are getting error, I reckon you are using new version.

So you should use $('select.widthOpts').selectedIndex=index; where index is a integer value that you already know the position of the required option in selectmenu

Harry
  • 1,572
  • 2
  • 17
  • 31
fnagel
  • 654
  • 4
  • 11
  • Where do i find out how to handle the index and value from what the selectmenu use to be? Because I need to be about to set the index and value like before. What is the work around, and can you tell me how to find the docs located at github? I am new to github – Filling The Stack is What I DO Feb 21 '13 at 18:16
  • Which version you are using? Old version has methods for this. In the new version you will need to get these values from the original select: `mySelect[0].selectedIndex` and `mySelect[0].value` ps: would you mind +1 my answer? – fnagel Nov 11 '13 at 12:55
  • .selectedIndex will return the index and to set the index use .prop('selectedIndex', index_value); – Harry Aug 01 '14 at 00:03