Ullas
Ullas

Reputation: 383

phonegap in android multiple pages

I am a new user in phonegap in android. I am trying to create a project with multiple pages within one html file but it is not working. The code i have used is shown below

<!DOCTYPE html> 
<html> 
    <head> 
    <meta charset="utf-8" /> 
    <title>Page Title</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" /> 
    <script src="http://code.jquery.com/jquery-1.5.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script> 
<body> 

<!-- Start of first page --> 
<div data-role="page" id="foo"> 

    <div data-role="header"> 
        <h1>Foo</h1> 
    </div><!-- /header --> 

    <div data-role="content">   
        <h2>Foo</h2> 
        <p>I'm first in the source order so I'm shown as the page.</p>      
        <p>View internal page called <a href="#bar">bar</a></p> 
        <p>View internal page called <a href="#baz" data-rel="dialog" data-transition="pop">baz</a> as a dialog.</p> 
    </div><!-- /content --> 

    <div data-role="footer"> 
        <h4>Page Footer</h4> 
    </div><!-- /footer --> 
</div><!-- /page --> 


<!-- Start of second page --> 
<div data-role="page" id="bar"> 

    <div data-role="header"> 
        <h1>Bar</h1> 
    </div><!-- /header --> 

    <div data-role="content">   
        <h2>Bar</h2> 
        <p>I'm the bar page.</p>        
        <p><a href="#foo" data-direction="reverse">Back to foo</a></p>  
    </div><!-- /content --> 

    <div data-role="footer"> 
        <h4>Page Footer</h4> 
    </div><!-- /footer --> 
</div><!-- /page --> 


<!-- Start of second page --> 
<div data-role="page" id="baz"> 

    <div data-role="header"> 
        <h1>Baz</h1> 
    </div><!-- /header --> 

    <div data-role="content">   
        <h2>Baz</h2> 
        <p>I'm the baz page, viewed as a dialog.</p>        
        <p><a href="#foo" data-rel="back">Back to foo</a></p>   
    </div><!-- /content --> 

    <div data-role="footer"> 
        <h4>Page Footer</h4> 
    </div><!-- /footer --> 
</div><!-- /page --> 

</body> 
</html> 

Kindly look into this and i appreciate any help that would be available in this regard.

Upvotes: 0

Views: 4714

Answers (5)

Erickaj
Erickaj

Reputation: 13

McDowell is right, you are missing the </head> tag

Also, make sure your .js and .css sources are saved locally and the path to them is relative, not absolute.

Rewrite as:

<link rel="stylesheet" href="jquery.mobile-1.0a3.min.css" />
<script src="jquery-1.5.min.js"></script>
<script src="jquery.mobile-1.0a3.min.js"></script>

And don't forget the PhoneGap/Cordova .js!

Upvotes: 1

Bohr
Bohr

Reputation: 1882

It seems that you missed the </head>.

After adding it, your code works fine.

Upvotes: 0

dhaval
dhaval

Reputation: 7659

Works fine in the fiddle. Also your page layout and jquery mobile page layout also seems correct.

http://jsfiddle.net/dhavaln/Lbe6P/

Upvotes: 0

Islam
Islam

Reputation: 11

You need to create for each page a div that has a data-role type = page with name unique id

Also, all pages must be stored with the same html file call

<a href="#page_id">bar</a>



    <div data-role="page" id="foo" data-theme="b">
<div data-role="content">   
    <h2>Foo</h2> 
    <p>I'm first in the source order so I'm shown as the page.</p>      
    <p>View internal page called <a href="#foo2">bar</a></p> 
    <p>View internal page called <a href="#foo2" data-rel="dialog" data-transition="pop">baz</a> as a dialog.</p> 
</div><!-- /content --> 

<div data-role="footer"> 
    <h4>Page Footer</h4> 
</div>



<div data-role="page" id="foo2" data-theme="b">
<div data-role="content">   
    <h2>Foo2</h2> 

</div><!-- /content --> 

<div data-role="footer"> 
    <h4>Page Footer</h4> 
</div>

Upvotes: 1

fynnbob
fynnbob

Reputation: 573

Each page needs to be enclosed in a div with data-role='page'. For multiple pages you should include an id for each page as well.

Eg.

<div data-role='page' id='page-foo'>
  <div data-role="content">   
    <h2>Foo</h2> 
    <p>I'm first in the source order so I'm shown as the page.</p>      
    <p>View internal page called <a href="#bar">bar</a></p> 
    <p>View internal page called <a href="#baz" data-rel="dialog" data-transition="pop">baz</a> as a dialog.</p> 
  </div><!-- /content --> 

  <div data-role="footer"> 
    <h4>Page Footer</h4> 
  </div><!-- /footer --> 
</div>

Upvotes: 0

Related Questions