Template update only first time

2 posts, 0 answers
  1. Petr
    Petr avatar
    9 posts
    Member since:
    Feb 2013

    Posted 04 Nov 2013 Link to this post

    Hi,
    template for collection update only for first push.
    Click add button and only first time template rerender.
    http://jsfiddle.net/gDVwS/1/

    Thank
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 06 Nov 2013 Link to this post

    Hello Petr,

    In order to fix this issue you should reference the data directly:
    activeData: function(){
        var result;
        $.each(this.data, function(index, item){
            if (item.active == true) {
                result = item;
                return false;
            }
        });
         
        return result;
    }

    Here is a link to the updated jsFiddle:
    On a side note, using jQuery.each in this case might affect onto the performance. My recommendation is to either use a standard for loop or jQuery map method which is faster.

    Regards,
    Alexander Valchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
Back to Top