I m starting with phonegap and also trying to apply JavaScript OOP with it. But the problem are the method calls and stuff. imagine this:
I have a main controller in JavaScript, this file try to control most of the work-flow between network calls, database a change views.
This is my main.js.
var onlineStatus = false;
var mainModel;
var connectTo = "http://192.168.1.65/mobile/service/";
document.addEventListener("deviceready", onDeviceReady, false);
document.addEventListener("online", online, false);
document.addEventListener("offLine", offline, false);
function whenOnline() {
setOnline(true);
}
function whenOffline() {
setOnline(false);
}
function onDeviceReady() {
mainModel = new MainModel();
mainModel.openDatabase();
mainModel.startApplication();
}
而主编是:
function MainModel() {
this.isOnline = false;
this.database = null;
this.login = null;
this.getDatabase = function() {
return this.database;
};
this.openDatabase = function() {
this.login = new LoginModel();
this.database = window.openDatabase("wayacross", "0.2", "Test DB", 1000000);
};
this.startApplication = function() {
this.database.transaction(this.login.checkLogin, goLoggin);
};
}
And the Login Model:
function LoginModel() {
this.loginError = function() {
navigator.notification.alert( Login Error , // message
null, // callback
Login , // title
Done // buttonName
);
goLogin();
};
this.isLogged = function(tx, results) {
//ajax code
};
this.checkLogin = function(tx) {
alert( checkLogin: Variable TX = + tx);
tx.executeSql( SELECT * FROM login , [], this.isLogged, this.loginError);
};
}
这是我目前掌握开始工作流程的守则。 问题在于,在主编Model.jsthis.database.transaction(Rologin.check Carloin, go Carlogin);它只得一 nothing。 当我改变这一行文时,行文记录仪的行文是行文,但 t变却未定。
我可能在这里做一些错误,但我不知道为什么。 Maybe Javagust OOP没有电话支持,我确实不相信。
你们能否帮助?
Thanks in advance,
Elkas