Reputation: 211
In Jquery mobile, how to open another page, when focus(click) on input ?
This is what I tried This..
<input type="text" name="" id="" value="" class="move">
$(document).on('focus', '.move', function() {
$('#page2').page('open');
});
<div data-role="page" id="page2">
Test
</div>
But it doesn't works
Can anyone help me ?
Upvotes: 1
Views: 322
Reputation: 57309
Depending on jQuery Mobile version you are using:
<input type="text" name="" id="" value="" class="move">
$(document).on('focus', '.move', function() {
$.mobile.changePage('#page2');
});
<div data-role="page" id="page2">
Test
</div>
Read more about it here.
This will also work in jQuery Mobile 1.4 but at this point this function is deprecated. If you are using pagecontainer widget then don't use this function at all in jQUery Mobile 1.4
This version has implemented pagecontainer widget.
$( ":mobile-pagecontainer" ).pagecontainer( "change", "confirm.html");
Read more about it here.
Upvotes: 3
Reputation: 2701
Use this , because cannot call methods on page prior to initialization
$(document).on('focus', '.move', function() {
$.mobile.changePage('#page2', { transition: "pop", role: "dialog", reverse: false } );
});
Upvotes: -1