0

I need a nicely formatted form on onsen ui but i cant. Can someone help. Also the page navigation is not working when i have different hmtl files

window.fn.pushPage = function (page, anim){ if (anim) { document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title }, animation: anim }); } else { document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title } }); } };

1 Answers1

0

To achieve a smooth navigation on your multipaged mobile html site using onsen UI, you have to do the following:

1) Insert the tag in the index.html page. This should be placed inside the tag example is shown below

 <!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta http-equiv="Content-Security-Policy"
          content="default-src * data:; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
    <script src="lib/onsenui/js/onsenui.min.js"></script>
    <link rel="stylesheet" href="lib/onsenui/css/onsenui.css">
    <link rel="stylesheet" href="lib/onsenui/css/onsen-css-components.css">

</head>
<body>

<ons-navigator id="navigator" var="navigator"></ons-navigator>

......
</body>
</html>

2) Your inner pages should not have a opening tag, or other similar tags, but should look somewhat as shown below (assuming this page is my-second-page.html)

<ons-page id="my-second-page">

 .......


</ons-page>

3) To navigate from my-second-page to my-third-page.html, use the Onsen UI pushPage function as shown below. This is a javascript snippet that will be placed in your javasript file. This code will be executed when a user clicks a button to navigate to my-third-page.html

document.querySelector('#navigator').pushPage('my-third-page.html');