cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblot...@apache.org
Subject cordova-app-hello-world git commit: CB-10522: Event binding in Hello World is misleading
Date Tue, 16 Feb 2016 21:46:33 GMT
Repository: cordova-app-hello-world
Updated Branches:
  refs/heads/master 11666b070 -> 4413480de


CB-10522: Event binding in Hello World is misleading

Fixing the Hello World example


Project: http://git-wip-us.apache.org/repos/asf/cordova-app-hello-world/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-hello-world/commit/4413480d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-hello-world/tree/4413480d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-hello-world/diff/4413480d

Branch: refs/heads/master
Commit: 4413480de85942a008d2dd0a820e128656d58cf5
Parents: 11666b0
Author: Sarangan Rajamanickam <sarajama@microsoft.com>
Authored: Fri Feb 5 11:25:34 2016 -0800
Committer: Sarangan Rajamanickam <sarajama@microsoft.com>
Committed: Tue Feb 16 13:32:40 2016 -0800

----------------------------------------------------------------------
 package.json    |  3 ++-
 www/js/index.js | 17 ++++++-----------
 2 files changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-app-hello-world/blob/4413480d/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 0f9532d..618aeb9 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,8 @@
   },
   "main": "index.js",
   "keywords": [
-    "ecosystem:cordova"
+    "ecosystem:cordova",
+    "cordova:template"
   ],
   "author": "Apache Software Foundation",
   "license": "Apache version 2.0"

http://git-wip-us.apache.org/repos/asf/cordova-app-hello-world/blob/4413480d/www/js/index.js
----------------------------------------------------------------------
diff --git a/www/js/index.js b/www/js/index.js
index c31cd83..6963dc9 100644
--- a/www/js/index.js
+++ b/www/js/index.js
@@ -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);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message