In a hybrid mobile app I'm working on I can't call functions or methods from external classes. I've simplified the code to just this:
var hub_api = (function() {
function send() {
console.log('hub api called');
};
return {
send: function() {
send();
}
};
});
which is called like this:
(function() {
function register_event_handlers() {
$(document).on(" touchend", "#btntest", function(evt) {
hub_api.send();
alert('pressed test button');
});
}
document.addEventListener("app.Ready", register_event_handlers, false);
})();
The actual code works fine in another project. The scripts are both included like this:
<script type="application/javascript" src="js/helpers/api.js"></script>
<script type="application/javascript" src="js/helpers/testclass.js"></script>
Running the app returns hub_api is not defined
. I'm completely stumped. Any help is appreciated.
Edit: I found when I put the hub_api function in app.js it works as expected but still does not when included in a separate api.js script. The scripts are called in the correct sequence.