JQuery Mobile .selectmenu无效

时间:2014-05-26 10:44:09

标签: jquery jquery-mobile

我正在使用Jquery Mobile和Jquery开发一个网站,我使用JSON动态更新下拉列表的值,但下拉列表中的值不显示更新值。我正在尝试使用selectmenu("刷新")并触发("更改")但我无法工作。

Html代码:

                    <div class="row-fluid"> 
                        <div class="span3 form-inline">
                            @Html.DropDownList("credit_card_expiry_month", CCMonthList, "Month", new { id = "credit_card_expiry_month", @class = "font12 required", autocomplete = "off" })  
                        </div>

                        <div class="span4 form-inline">
                            @Html.DropDownList("credit_card_expiry_year", CCYearList, "Year", new { id = "credit_card_expiry_year", @class = "font12 required", autocomplete = "off" }) 
                            <label id="err_credit_card_expiry" class="text-error" style="margin-top:3px;"></label>
                        </div>

                    </div>

                    <div class="row-fluid"> 
                        @Html.DropDownList("credit_card_issuing_bank_country", (IEnumerable<SelectListItem>)ViewBag.CountriesListItem, "Issuing bank country", new { id = "credit_card_issuing_bank_country", @class = "required", autocomplete = "off" })                                   
                    </div>

JSON函数调用

function LoadCardInfo()
 {
     $.getJSON("GetCardInfo", function (result) {
         if (result != null) {
             $("#credit_card_number").val(result.credit_card_no);
             $("#credit_card_holder_name").val(result.card_holder_name);
             $("#credit_card_expiry_month").val(result.expiry_month);
             $("#credit_card_expiry_year").val(result.expiry_year);
             $("#credit_card_issuing_bank_country").val(result.issuing_bank_country_code_A2);
             $("#credit_card_issuing_bank_name").val(result.issuing_bank_name);
             LoadCardIcon(result.credit_card_no);
         } else {

         }
     });

 }

$('document').on('pageshow', function () {
    $("#credit_card_expiry_month").trigger("change");
    $("#credit_card_expiry_month").selectmenu('refresh', true);
});

1 个答案:

答案 0 :(得分:2)

我认为你错过#来匹配一个id选择器,试试:

$('document').on('pageshow', function () {
    $("#credit_card_expiry_month").trigger("change");
    $("#credit_card_expiry_month").selectmenu('refresh', true);
});