我几乎盯着这个问题:我正在使用KendoUI的dataSource和一些过滤器来进行某种ajax-search: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();
。每隔一段时间,结果计数就不会出现。有谁知道为什么?
谢谢,