Skip to content
Permalink
Browse files
CB-10522: Event binding in Hello World is misleading
Fixing the Hello World example
  • Loading branch information
sarangan12 committed Feb 16, 2016
1 parent 11666b0 commit 4413480de85942a008d2dd0a820e128656d58cf5
Showing 2 changed files with 8 additions and 12 deletions.
@@ -8,7 +8,8 @@
},
"main": "index.js",
"keywords": [
"ecosystem:cordova"
"ecosystem:cordova",
"cordova:template"
],
"author": "Apache Software Foundation",
"license": "Apache version 2.0"
@@ -19,22 +19,17 @@
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},

// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
// Bind any cordova events here. Common events are:
// 'pause', 'resume', etc.
onDeviceReady: function() {
app.receivedEvent('deviceready');
this.receivedEvent('deviceready');
},

// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);

0 comments on commit 4413480

Please sign in to comment.