user3400080
user3400080

Reputation: 211

How to open page when focus(click) input in jquery mobile?

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

Answers (2)

Gajotres
Gajotres

Reputation: 57309

Depending on jQuery Mobile version you are using:

jQuery Mobile 1.3 and below:

<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

jQuery Mobile 1.4:

This version has implemented pagecontainer widget.

$( ":mobile-pagecontainer" ).pagecontainer( "change", "confirm.html");

Read more about it here.

Upvotes: 3

Ved
Ved

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

Related Questions