3

I'm using 1.4 so the changePage() technique is deprecated and I'd rather not use it...

http://api.jquerymobile.com/jQuery.mobile.changePage/

I have this code:

$("select.start").change(function() {
  alert('test');
  $("#home").pagecontainer("change", "#pick");
  //$("#pick").pagecontainer("change");
});

Neither of the above worked -- the 'change' event is firing but when the select option is selected no page #pick is positioned into place as I require.

Can someone show me what I might be doing wrong?

EDIT |

<select class="start">    <option>Item 1 (Last Done: 2.4 weeks ago)</option> 
  <optgroup label="Section B"> 
    <option value="#">Standing</option> 
  </optgroup>  
</select>

The <optgroup> doesn't seem to make a difference

Alex.Barylski
  • 2,843
  • 4
  • 45
  • 68

1 Answers1

6

You can call

$(':mobile-pagecontainer').pagecontainer('change', '#pick');

for example,

http://jsfiddle.net/LDyx6/

js

function test() {
    $(':mobile-pagecontainer').pagecontainer('change', '#page2');
}

html

<div id="page1" data-role="page" data-theme="a">
    <div data-role="header">
        <h1>page1</h1>
    </div>
    <div data-role="content">
         <a href="#page2" data-role="button"> go to page2</a>
        <a href="#" data-role="button" onclick="test()"> go to page2 (script)</a>
    </div>
</div>

<div id="page2" data-role="page" data-theme="b">
    <div data-role="header">
        <h1>page2</h1>
            <a href="#page1" data-role="button" data-direction="reverse" data-icon="back">back</a>
    </div>
    <div data-role="content"></div>
</div>
melc
  • 11,523
  • 3
  • 36
  • 41
  • Thank you that seems to have done the trick...where is this documented? How did you figure out ':mobile-pagecontainer' was the trick? – Alex.Barylski Dec 31 '13 at 16:49
  • 1
    @Alex.Barylski i'm glad it worked well. It is used in http://api.jquerymobile.com/pagecontainer/ but unfortunately not described. It is also mentioned by other users as well. – melc Dec 31 '13 at 16:56
  • Now is there a way to pass arguments to each page? The documentation is not very clear on that or how it's done :s – Alex.Barylski Jan 10 '14 at 21:29