majorpay
14 Nov 2007, 8:12 AM
This is a simple class I have created for mapping my keys:
var KeyNavClass = function(){
var keynav;
var keymap;
return {
init:function(isContactSheet){
keynav = new Ext.KeyNav(document, {
"up" : function(e){
if (!(isContactSheet)) {
ImageClass.prevImage();
}
return true;
},
"down" : function(e){
if (!(isContactSheet)){
ImageClass.nextImage();
}
return true;
},
"left" : function(e){
if (isContactSheet){
ContactClass.prevImage();
}else{
ImageClass.prevPage();
}
return true;
},
"right" : function(e){
if (isContactSheet){
ContactClass.nextImage();
}else{
ImageClass.nextPage();
}
return true;
},
scope : this
});
keymap = new Ext.KeyMap(document,[{
key:"aA",
fn:function(){
if (isContactSheet){
ContactClass.thumbsup();
}else{
ImageClass.thumbsup();
}
}
},{
key:"rR",
fn:function(){
if (isContactSheet){
ContactClass.thumbsdown();
}else{
ImageClass.thumbsdown();
}
}
}]);
},
kmDisable:function(){keymap.disable();},
kmEnable:function(){keymap.enable();}
}
}();
What this class does is based on what view the interface is in, it remaps the keys (or is supposed to). Instead of remapping when I call init the second time, it adds the new functionality on top of the old functionality (so the event fires two methods). How do I remove an event in javascript in order to REPLACE it instead of compound it?
One more thing - I have tried "keynav = null' before keynav = new and that did not solve this problem.
var KeyNavClass = function(){
var keynav;
var keymap;
return {
init:function(isContactSheet){
keynav = new Ext.KeyNav(document, {
"up" : function(e){
if (!(isContactSheet)) {
ImageClass.prevImage();
}
return true;
},
"down" : function(e){
if (!(isContactSheet)){
ImageClass.nextImage();
}
return true;
},
"left" : function(e){
if (isContactSheet){
ContactClass.prevImage();
}else{
ImageClass.prevPage();
}
return true;
},
"right" : function(e){
if (isContactSheet){
ContactClass.nextImage();
}else{
ImageClass.nextPage();
}
return true;
},
scope : this
});
keymap = new Ext.KeyMap(document,[{
key:"aA",
fn:function(){
if (isContactSheet){
ContactClass.thumbsup();
}else{
ImageClass.thumbsup();
}
}
},{
key:"rR",
fn:function(){
if (isContactSheet){
ContactClass.thumbsdown();
}else{
ImageClass.thumbsdown();
}
}
}]);
},
kmDisable:function(){keymap.disable();},
kmEnable:function(){keymap.enable();}
}
}();
What this class does is based on what view the interface is in, it remaps the keys (or is supposed to). Instead of remapping when I call init the second time, it adds the new functionality on top of the old functionality (so the event fires two methods). How do I remove an event in javascript in order to REPLACE it instead of compound it?
One more thing - I have tried "keynav = null' before keynav = new and that did not solve this problem.