I'm trying to implement the below jQuery calls to be used in my Ember Controller as actions.
jQuery (taken from http://ift.tt/2wFdpTK):
$('#checkAll').click(function(){
for(i=0; i < chart.series.length; i++) {
if(chart.series[i].selected == false){
chart.series[i].select();
showSeries.call(chart.series[i], {checked: true});
}
}
});
$('#uncheckAll').click(function(){
for(i=0; i < chart.series.length; i++) {
if(chart.series[i].selected == true){
chart.series[i].select();
showSeries.call(chart.series[i], {checked: false});
}
}
});
Implementation in Ember:
checkAll() {
Ember.$('#checkAll').click(function(){
for(i=0; i < chart.series.length; i++) {
if(chart.series[i].selected == false){
chart.series[i].select();
showSeries.call(chart.series[i], {checked: true});
}
}
});
},
uncheckAll() {
Ember.$('#uncheckAll').click(function(){
for(i=0; i < chart.series.length; i++) {
if(chart.series[i].selected == true){
chart.series[i].select();
showSeries.call(chart.series[i], {checked: false});
}
}
});
},
But I'm getting the error: "i is not defined"
when I click the buttons:
checkAll: function checkAll() {
_ember['default'].$('#checkAll').click(function () {
for (i = 0; i < chart.series.length; i++) { <== error here
if (chart.series[i].selected == false) {
chart.series[i].select();
showSeries.call(chart.series[i], { checked: true });
}
}
});
},
What is wrong here?
Aucun commentaire:
Enregistrer un commentaire