正在更新部分JS Api OcoberCMS



我正在尝试使用AJAX 对表进行排序

ScheduleC.php

public function onSort() {
$groupId = (int)post('groupid');
$professorId = (int)post('professorid');
$schedules = Schedule::orderBy('date', 'desc')->get();
if (($groupId) && ($groupId!='-1')) {
$this->sortByGroup($groupId, $schedules);
}
if (($professorId) && ($professorId!='-1')) {
$this->sortByProfessor($professorId, $schedules);
}
$this->schedule = $this->page['schedule'] = $schedules;

return  $this->page['schedule'];
}

默认.php

<div id="schedule-table-container">
{% partial '@schedule-table' %}
</div>

schedule.js

$(document).ready(function() {
$('#sortschedule').submit(function(event) {
event.preventDefault();
$(this).request('onSort', {         
update: {'schedulec::schedule-table': '#schedule-table-container'},
success: function(data) {
console.log(data);
this.success(data);
}
});
});
});

函数返回正确的数据,但不更新partial。

最有趣的是,类似的代码正在我的另一个项目中工作。请帮帮我。

这里真正的问题是因为调用了success选项。点击此处阅读更多信息。因此,不从服务器返回任何内容的解决方案不会执行success()选项来停止ajaxUpdate

"Success((|在请求成功的情况下执行的回调函数。如果提供此选项,它将覆盖默认框架的功能:元素不更新,beforeUpdate事件不触发,ajaxUpdateajaxUpdateComplete事件不触发。事件处理程序获得3个参数:从服务器接收的数据对象、文本状态字符串和jqXHR对象。但是,您仍然可以在函数内部调用调用this.success(…(的默认框架功能">

我通过删除处理程序中的返回来解决问题

最新更新