Crystal
Crystal

Reputation: 21

JQuery Mobile .selectmenu not working

I am developing a website using Jquery Mobile and Jquery, and i update the value of dropdown dynamically with JSON, but the value in dropdown doesn't show the update value. I am trying to using selectmenu("refresh") and trigger("change") but i doesn't work.

Html code:

                    <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 call

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);
});

Upvotes: 0

Views: 175

Answers (1)

Irvin Dominin
Irvin Dominin

Reputation: 30993

I think you are missing the # to match an id selector, try:

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

Upvotes: 2

Related Questions