I'm having a problem with my piece of code as the "this.items" variable turns to undefined when entering the following forEach. As you can see there are to console.log that show that the this.items if redefined in the forEach
Why?
FYI, I'm using jQuery 1.8 and Classy (class manager for jQuery)
extractParams : function(params){
if(params != ""){
this.items = {};
params = params.split("&");
console.log(this.items);
params.forEach( function(dts){
console.log(this.items); // = undefined
this.keyval = dts.split("=");
console.log(this.items);
switch(keyval[0]){
case "v" :
this.items["Version number"] = this.keyval[1];
params = params.filter(function(v) { return !(v === "v=" + this.keyval[1] );});
break;
case "t1" :
console.log(this.item);
this.items["Event Type"] = this.keyval[1];
params = params.filter(function(v) { return !(v === "t1=" + this.keyval[1] );});
break;
default :
case "" :
break;
}
switch(true){
case regItem.test(keyval[0]):
this.items["Product Id n°" + this.keyval[0].match(regexpParamNumber)[1]] = this.keyval[1];
params = params.filter(function(v) { return !(v === "i"+this.keyval[0].match(regexpParamNumber)+"=" + this.keyval[1] );});
break;
case regQuantity.test(keyval[0]):
this.items["Quantity n°" + keyval[0].match(regexpParamNumber)[1]] = keyval[1];
params = params.filter(function(v) { return !(v === "q"+keyval[0].match(regexpParamNumber)+"=" + keyval[1] );});
break;
default :
case "" :
break;
}
})
console.log(result);
result[0] = detectTrackerType(this.items);
show(result);
}
return this.items;
}