jquery selectMenu refresh doesn't work

落爺英雄遲暮 提交于 2020-01-14 04:47:08

问题


I have a selectMenu that I initialized and later I want to populate it with some data:

$.each(data, function (Key, Value) {
    $('#ddlReportFarms').append($("<option></option>")
    .attr("value", Value.ID)
    .text(Value.Name));
});                    
$('#ddlReportFarms').selectmenu('refresh', true);

this doesn't work for some reason, the new items are not display. if I do this instead of the refresh:

$('#ddlReportFarms').selectmenu();

the items are displayed, but when this happens again, the selectMenu duplicates itself (appears twice) and becomes buggy..

anyone? thanks Igal


回答1:


I believe you have to do it like this:

[... your other code...]
$('#ddlReportFarms').selectmenu({'refresh': true});



回答2:


Thanks MilkyWayJoe

when I write it like you suggested, the selectMenu duplicates itself, just creates another selectmenu as many times as I run the refresh.. frustrating. this is the HTML after the refresh:

<a id="ddlReportFarms-button" class="ui-selectmenu ui-widget ui-state-default ui-corner-all ui-selectmenu-dropdown" aria-owns="ddlReportFarms-menu" aria-haspopup="true" href="#" role="button" style="width: 198px;">
<span class="ui-selectmenu-status">Select Farm</span>
<span class="ui-selectmenu-icon ui-icon ui-icon-triangle-1-s"></span>
</a>
<a id="ddlReportFarms-button" class="ui-selectmenu ui-widget ui-state-default ui-selectmenu-dropdown ui-corner-all" aria-owns="ddlReportFarms-menu" aria-haspopup="true" href="#" role="button" style="width: 198px;">
<span class="ui-selectmenu-status">Select Farm</span>
<span class="ui-selectmenu-icon ui-icon ui-icon-triangle-1-s"></span>
</a>



回答3:


Which version of selectmenu do you use?

My fork has no method refresh but your proposal is correct (aka uing selectmenu() on a already initialized selectmenu to refresh it). Please see the wiki for more information: https://github.com/fnagel/jquery-ui/wiki/Selectmenu



来源:https://stackoverflow.com/questions/10471780/jquery-selectmenu-refresh-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!