BackgroundTeam
13 Apr 2012, 1:52 AM
What I'm trying to do in this piece of code is to put the functions anadir y quitar as listeners of the check and uncheck events of a checkboxfield.
If you see (despite my noobie condition), I'm trying also the pass the label of the checkboxfield itself as a parameter of the function.
Is this possible? What I'm doing wrong?
Thank you so much in advance. I'm only a beginner in Sencha and any help is so appreciated.
// Rest of declaration of view here
{
xtype: 'checkboxfield',
label: 'Noir',
listeners: {
check: anadir(label)
},
{
uncheck: quitar(label)
}
}
}
]
}
]
}
});
anadir: function(label){
console.log("Aņadiendo...");
var index = storemisOpciones.getCount() - 1;
console.log("Indice: " + index);
storemisOpciones.add({option: label});
console.log(label + " se ha marcado");
index = storemisOpciones.getCount() - 1;
console.log("Indice: " + index);
console.log(storemisOpciones.getAt(index));
storemisOpciones.sync();
}
quitar: function(label){
console.log("Quitando...");
var index = storemisOpciones.getCount() - 1;
console.log("Indice: " + index);
var record = storemisOpciones.findRecord('option', label);
storemisOpciones.remove(record);
console.log(label + " se ha quitado");
index = storemisOpciones.getCount() - 1;
console.log("Indice: " + index);
storemisOpciones.sync();
}
If you see (despite my noobie condition), I'm trying also the pass the label of the checkboxfield itself as a parameter of the function.
Is this possible? What I'm doing wrong?
Thank you so much in advance. I'm only a beginner in Sencha and any help is so appreciated.
// Rest of declaration of view here
{
xtype: 'checkboxfield',
label: 'Noir',
listeners: {
check: anadir(label)
},
{
uncheck: quitar(label)
}
}
}
]
}
]
}
});
anadir: function(label){
console.log("Aņadiendo...");
var index = storemisOpciones.getCount() - 1;
console.log("Indice: " + index);
storemisOpciones.add({option: label});
console.log(label + " se ha marcado");
index = storemisOpciones.getCount() - 1;
console.log("Indice: " + index);
console.log(storemisOpciones.getAt(index));
storemisOpciones.sync();
}
quitar: function(label){
console.log("Quitando...");
var index = storemisOpciones.getCount() - 1;
console.log("Indice: " + index);
var record = storemisOpciones.findRecord('option', label);
storemisOpciones.remove(record);
console.log(label + " se ha quitado");
index = storemisOpciones.getCount() - 1;
console.log("Indice: " + index);
storemisOpciones.sync();
}