Mark Burgoyne
Mark Burgoyne

Reputation: 1594

How to update popup selection text with JQueryMobile 1.4RC1?

I've previously used popups with JQueryMobile 1.3 and older without problem. With the new 1.4 RC1 I'm finding my popups don't update when I select a different item.

You can see an example here with JQueryMobile 1.3 http://jsfiddle.net/vinomarky/56hQ9/

And another here using JQueryMobile 1.4RC1 - identical code, but the select box no longer updates when different options are chosen; http://jsfiddle.net/vinomarky/B9TqL/1/

Any ideas of what to try? the code is as follows;

<a href="#popupBasic16" data-rel="popup" data-role="button" data-inline="true" data-position-to="origin" id="log_or_norm">Lognormal</a>

<div data-role="popup" id="popupBasic16">
    <div data-role="fieldcontain">
        <fieldset data-role="controlgroup">
            <input type="radio" name="updown" id="updown46" value="Lognormal" checked="checked" />
            <label for="updown46">Lognormal</label>
            <input type="radio" name="updown" id="updown47" value="Normal" />
            <label for="updown47">Normal</label>
        </fieldset>
    </div>
</div>

And Javascript

$('select').selectmenu();

$('#updown46').click(function () {
    $('#log_or_norm .ui-btn-text').html('Lognormal');
    $('#popupBasic16-screen').click();
    document.select_choices.log_or_norm.value = "Lognormal";
    $('select').selectmenu('refresh');
});

$('#updown47').click(function () {
    $('#log_or_norm .ui-btn-text').html('Normal');
    $('#popupBasic16-screen').click();
    document.select_choices.log_or_norm.value = "Normal";
    $('select').selectmenu('refresh');
});

Upvotes: 1

Views: 479

Answers (2)

Sridhar R
Sridhar R

Reputation: 20418

Two methods

 $('#log_or_norm').text('Normal');

Another

$('#log_or_norm ').empty().append('Lognormal');

Fiddle

http://jsfiddle.net/B9TqL/3/

Upvotes: 2

Jonathan Naguin
Jonathan Naguin

Reputation: 14796

Your Javascript has some errors as document.select_choices is not defined. If you want to update the value of your button use jQuery:

$('#log_or_norm').text("Lognormal");

It seems that in jQuery 1.4 they changed the HTML structure of the buttons, that's why your code $('#log_or_norm .ui-btn-text').html('Lognormal'); doesn't work. Check the full page of changes here.

Demo here.

Upvotes: 2

Related Questions