0
我需要在下拉菜单中填充来自web服务的项目后选择默认值。如何检测下拉项目的负载是否已完成?如何在下拉的加载完成后运行某些操作
<select id="countriesList"
data-url="@Url.Action("GetAllCountries", "Countries", new { Area = "Panel" })"
data-bind="options: countries, optionsValue: 'ID', optionsText: 'Name', optionsCaption: 'Selecione um país', value: selectedCountry">
</select>
而且JS:
$.getJSON($('#countriesList').data('url'), function (data) {
self.countries(data);
});
需要知道如何填充下拉列表... – Nick
您可以使用'getJson'方法的'Success'回调选项吗? http://api.jquery.com/jQuery.getJSON/ 敲除之前可能会发生绑定它,但? –
这就是问题所在,如果由于某种原因而需要花费很多时间从getJson方法中添加项目,那么可能会遇到异步执行问题。 –