Listview Click event

2 posts, 0 answers
  1. Chuck
    Chuck avatar
    1 posts
    Member since:
    Jan 2014

    Posted 21 Jan 2015 Link to this post

    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

            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;
                 } else {
                     currentItems = $.grep(currentItems, function(o) {
                       return o.blog_id !== item.blog_id;
                ViewModel.set("itemsource", currentItems);
  2. Petyo
    Petyo avatar
    2436 posts

    Posted 23 Jan 2015 Link to this post

    Hi Chuck,

    this seems unlikely. Unless I am missing something, the code you have posted does not have any asynchronous calls in it, so the error probably is somewhere else. You can verify that by putting console.log at the start/end of the callback. 

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top