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?

0

1 Answer 1

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 )

Sign up to request clarification or add additional context in comments.

1 Comment

I want not do "$( "#software" ).val(1)", I just want to fire trigger every time when I change the value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.