How to select an option in a jQuery ui selectmenu dynamically?

后端 未结 6 1276
别跟我提以往
别跟我提以往 2021-02-18 21:44

After changing a menu from a regular select to a jQuery selectmenu, I can no longer select options in it programatically. Is there a way to do this?

The code to select

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-18 22:37

    Assuming that you have already done this part once before:

    $("#ListId").selectmenu({ style: "dropdown", width:140 });
    

    I found this works:

    $('#ListId').val(value);
    $('#ListId').selectmenu("refresh");
    

    This causes the the stylized drop down to show the correct value.

提交回复
热议问题