2

I got this selectmenu:

$( "#software" ).selectmenu({ 
    width : 'auto', 
    select: function( event, ui ) {
        //my code
    }
});

And I want to programmatically change the selected Item and trigger the 'select' state.

I do the following:

$( "#software" ).val( 1 ).selectmenu( "refresh" ).trigger( "select" );

The selectmenu picks the right option and refreshes it but it doesn't trigger the 'select' state. How can I do this?

T J
  • 42,762
  • 13
  • 83
  • 138
progNewbie
  • 4,362
  • 9
  • 48
  • 107

1 Answers1

10

You can do the following:-

$( "#software" ).val(1).selectmenu("refresh").trigger("selectmenuselect");

You will need to bind an event listener to the selectmenuselect event like:

$( "#software" ).on( "selectmenuselect", function( event, ui ) {
     alert('New Item Selected!')
});

Info: select( event, ui )

Ricardo Valeriano
  • 7,533
  • 1
  • 24
  • 34
palaѕн
  • 72,112
  • 17
  • 116
  • 136