This code shows (i.e. alerts) "alert1" but not "alert2". I'm using a Samsung Galaxy Tab 3 7.0 as target device. The following code is in index.js
.
EDIT: "alert3" is neither shown - for those who get dazed about javascript contexts and closures.
var app = {
bootStrap: function() {
//code here does not run
window.alert("alert2");
//document.body.style.backgroundColor = "blue";
},
initialize: function() {
var current = this;
//code here runs
window.alert("alert1");
document.addEventListener("deviceready", function(){
//code inside this anonymous function neither runs
window.alert("alert3");
current.bootStrap();
}, false);
}
};
The initialize
method is being called:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/platform.css" />
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/angular-route.min.js"></script>
<script type="text/javascript" src="js/angular-resource.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<title>1001Carros</title>
</head>
<body>
<script type="text/javascript">
app.initialize();
</script>
<div id="log">
<button id="clickme" value="Click Me"></button>
pantalla principal
</div>
</body>
</html>
Question: why? (also tried commenting and changing the background color to blue but neither line was executed at all).