I'm developing an application for mobile devices using the DHTMLX-touch framework, which is basically javascript.
I have a class A where this function is implemented:
A.prototype.initEventHandler = function(controller) {
$$('btn_submit').attachEvent('onItemClick', controller.switchView($$('ui_ewmon_main')));
}
First implementation
the object controller is an instance of the class B, and the class B is the following:
function B() {
//back button management
this.last_view=new Array();
this.current_view=this.ewmon_view.getRoot();
this.switchView = function(next) {
this.last_view[this.last_view.length]=this.current_view;
this.current_view=next;
next.show();
}
}
with firebug i get this error:
A.js:32Uncaught TypeError: Object # has no method 'switchView'
Second implementation
if I try to define switchView function as a prototype function:
function B() {
//back button management
this.last_view=new Array();
this.current_view=this.ewmon_view.getRoot();
}
B.prototype.switchView = function(next) {
this.last_view[this.last_view.length]=this.current_view;
this.current_view=next;
next.show();
}
in this case I get the following error:
B.js:13Uncaught TypeError: Cannot read property 'length' of undefined
Can anyone help me?
Thanks in advance Danilo
newto create the instance ofB?