Search code examples
jqueryhtmlmobiscroll

mobiscroll change the text of an option


If I use the following code I am able to change the text of a standard option:

$("#test option[value='100']").text("NEW TEXT");

This code does not work on options that are using mobiscroll. How can I get this to work?


Solution

  • Working example: http://jsfiddle.net/Gajotres/dqT9m/

    $('#index').live('pagebeforeshow',function(e,data){    
        $('#sel').mobiscroll().select({
            theme: 'ios',
            display: 'inline',
            mode: 'scroller',
            inputClass: 'i-txt',
            width: 200
        });  
        $("#sel").find("option[value='0']").text("NEW TEXT");
        $("#sel").parent().find('[data-val="_0"] div').text("NEW TEXT");
    });
    

    It is not enough to change option value, you also need to change plugin widget visible value.