【问题标题】:Timing issue: count being overwritten by results计时问题:计数被结果覆盖
【发布时间】:2012-11-14 21:19:32
【问题描述】:

我对这个问题几乎视而不见:我正在使用 KendoUI 的数据源和一些过滤器来进行一种 ajax 搜索:http://www.high-quality.nl/kandidaten/vacatures/。发生的事情是我的功能没有按正确的顺序执行。我的 dataSource 和 kendoObservable 如下所示:

var jobTemplate = kendo.template($('#job-stub').html());
var jobCount = new kendo.data.ObservableObject({
    count: 20
});

jobCount.bind('change', function(){
    if(this.count == 0){
        $('#result-wrapper').prepend('<h2>Er zijn geen vacatures gevonden.</h2>');
    } else if(this.count == 1){
        $('#result-wrapper').prepend('<h2>Er is <span class="blue">'+this.count+'</span> vacature gevonden.</h2>');
    } else {
        $('#result-wrapper').prepend('<h2>Er zijn <span class="blue">'+this.count+'</span> vacatures gevonden.</h2>');
    }
});

var jobData = new kendo.data.DataSource({
    transport: {
        read: {
            url: '/jobs/json/search',
            dataType: 'json',
            data: {
                job_matching_function: function(){
                    return $('#job_matching_function').val();
                },
                job_matching_type: function(){
                    return $('#job_matching_type').val();
                },
                job_matching_hours: function(){
                    return $('#job_matching_hours').val();
                },
                job_matching_education: function(){
                    return $('#job_matching_education').val();
                }
            }
        }
    },
    schema: {
        data: 'results'
    },
    change: function(){
        $('#result-wrapper').html(kendo.render(jobTemplate, this.view()));
        jobCount.set('count', this.view().length);
    }
});

当其中一个过滤器被点击时,我运行jobData.read();。时不时地不会出现结果计数。有人知道为什么吗?

谢谢,

  • 史蒂文

【问题讨论】:

    标签: ajax datasource kendo-ui


    【解决方案1】:

    史蒂文,我从未尝试在读取中使用 4 个匿名方法,不确定它的行为方式 - 尝试一次读取调用一次返回。然后你可以使用完整的事件,如post 所示。

    【讨论】:

      猜你喜欢
      • 2021-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-15
      相关资源
      最近更新 更多