Please check code below.
var $ = Dom7;
// Init App
var app = new Framework7({
on: {
init: function () {
//sqllite.initialize()
},
pageInit: function () {
console.log('Page initialized')
},
},
id: 'io.framework7.testapp',
root: '#app',
theme: "ios",
fastClicks: true,
init: true,
modalCloseByOutside: false,
popupCloseByOutside: false,
domCache: false,
dynamicNavbar: true,
modalCloseByOutside: true,
swipeBackPage: false,
actionsCloseByOutside: false,
initOnDeviceReady:true,
data: function () {
return {
user: {
firstName: 'John',
lastName: 'Doe',
},
};
},
methods: {
helloWorld: function () {
app.dialog.alert('Hello World!');
},
},
routes: routes,
// vi: {
// placementId: 'pltd4o7ibb9rc653x14',
// },
});
var mainView = app.views.create('.view-main', {
url: '/'
});
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
app.dialog.alert('Hello World!');
}
You don’t need install new deviceready handler, F7 does it for you (see initOnDeviceReady:true parameter)
Put app.dialog.alert(‘Hello World!’); to
on: {
init: function () {
//sqllite.initialize()
},
and it will work on device/emulator only, not in browser
Thank you for your reply.
When i tried to check navigator.device or navigator.camera in cordova, it’s giving me undefined error in device.
Do you include call cordova.js to index.html?
1 Like
Yes, sounds like there is no cordova.js
included or Device and Camera cordova plugins are not installed
1 Like