Skip to content

Instantly share code, notes, and snippets.

@evilnapsis
Created June 19, 2018 03:46
Show Gist options
  • Save evilnapsis/28386508474e57ac062dd8cf2f7b485d to your computer and use it in GitHub Desktop.
Save evilnapsis/28386508474e57ac062dd8cf2f7b485d to your computer and use it in GitHub Desktop.
Segundo ejemplo de Onsen UI, con paginas
<!-- Powered by http://evilnapsis.com -->
<!DOCTYPE html>
<html>
<head>
<title>Aplicacion Onsen UI</title>
<link rel="stylesheet" href="onsenui/css/onsenui.css">
<link rel="stylesheet" href="onsenui/css/onsen-css-components.min.css">
<script src="jquery.min.js"></script>
<script src="onsenui/js/onsenui.min.js"></script>
</head>
<body>
<ons-navigator swipeable id="myNavigator" page="page1.html"></ons-navigator>
<template id="page1.html">
<ons-page id="page1">
<ons-toolbar>
<div class="center">Pagina 1</div>
</ons-toolbar>
<ons-card >
<div class="title">Hola mundo!</div>
<div class="content">
<div>
Bienvenido a OnsenUI
</div>
<ons-button id="push-button">Ir a la pagina 2</ons-button>
</div>
</ons-card>
</ons-page>
</template>
<template id="page2.html">
<ons-page id="page2">
<ons-toolbar>
<div class="left"><ons-back-button>Pagina 1</ons-back-button></div>
<div class="center"></div>
</ons-toolbar>
<ons-card >
<div class="title">Segunda pagina!</div>
<div class="content">
<div>
Esta es la segunda pagina!
</div>
<ons-button id="push-button2">Ir a la pagina 3</ons-button>
</div>
</ons-card>
</ons-page>
</template>
<template id="page3.html">
<ons-page id="page3">
<ons-toolbar>
<div class="left"><ons-back-button>Pagina 2</ons-back-button></div>
<div class="center"></div>
</ons-toolbar>
<ons-card >
<div class="title">Tercera pagina!</div>
<div class="content">
<div>
Tercera pagina!
</div>
</div>
</ons-card>
</ons-page>
</template>
<script>
document.addEventListener('init', function(event) {
var page = event.target;
if (page.id === 'page1') {
page.querySelector('#push-button').onclick = function() {
document.querySelector('#myNavigator').pushPage('page2.html', {data: {title: 'Pagina 2'}});
};
}
else if (page.id === 'page2') {
page.querySelector('ons-toolbar .center').innerHTML = page.data.title;
page.querySelector('#push-button2').onclick = function() {
document.querySelector('#myNavigator').pushPage('page3.html', {data: {title: 'Pagina 3'}});
};
}
else if (page.id === 'page3') {
page.querySelector('ons-toolbar .center').innerHTML = page.data.title;
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment