Rohit
Rohit

Reputation: 705

Drop down value is not set (refresh ) in jquery mobile

I am using jquery mobile .I get value from drop down ,and save the value in local storage .But after reload or refersh it is not set the value. here is my fiddle. http://jsfiddle.net/ravi1989/pjkyw/

$(document).on('change', '#select-choice-1', function() {


 var fontFamily = $(this).val() ; 
alert(fontFamily)
    window.localStorage.setItem("FONTFAMILY", fontFamily);      

});

 var fontfamily= window.localStorage.getItem("FONTFAMILY");
        alert(fontfamily);
          if(fontfamily!=''){
            alert("Text")

            $('.fontFamily_h').val(fontfamily);


        }

Please click the first button on header (setting button).It show font family .The value of font family is not set after refresh

Upvotes: 0

Views: 3380

Answers (2)

Sheetal
Sheetal

Reputation: 1366

Use id of the drop down as selector instead of class ".fontFamily_h"

$('#select-choice-1').val(fontfamily).selectmenu("refresh");

This works!!!

Upvotes: 3

adamr
adamr

Reputation: 750

Add this :

$('#select-choice-1').selectmenu('refresh', true);

After:

$('.fontFamily_h').val(fontfamily);

Upvotes: 0

Related Questions