I have a mobile listview configured and working correctly to display a list of items that a user can select. They can select multiple items. When the user selects an item I simply add/remove the item from an array. The problem is that if they click the same item too fast then code code does not see the item in the array because the first pass through the click function hasn't finished when the second click happens.
Is there a way to handle this type of situation
$("#selectList").kendoMobileListView({
dataSource: ViewModel.get("itemsource"),
template: $("#tmpl-selection-list").text(),
pullToRefresh: false,
click: ViewModel.itemSelected
});
itemSelected: function(e){
var item = e.dataItem, addIt = true, currentItems = [];
currentItems = ViewModel.get("itemsource");
if(item !== null){
$.each(currentItems, function(s, _item){
if(item.blog_id === _item.blog_id){
addIt = false;
}
});
if(addIt){
currentItems.push(item);
} else {
currentItems = $.grep(currentItems, function(o) {
return o.blog_id !== item.blog_id;
});
}
ViewModel.set("itemsource", currentItems);
}
},
Is there a way to handle this type of situation
$("#selectList").kendoMobileListView({
dataSource: ViewModel.get("itemsource"),
template: $("#tmpl-selection-list").text(),
pullToRefresh: false,
click: ViewModel.itemSelected
});
itemSelected: function(e){
var item = e.dataItem, addIt = true, currentItems = [];
currentItems = ViewModel.get("itemsource");
if(item !== null){
$.each(currentItems, function(s, _item){
if(item.blog_id === _item.blog_id){
addIt = false;
}
});
if(addIt){
currentItems.push(item);
} else {
currentItems = $.grep(currentItems, function(o) {
return o.blog_id !== item.blog_id;
});
}
ViewModel.set("itemsource", currentItems);
}
},