我有这个问题。我正在使用yii2。我正在使用数据表来显示我的内容。一切都好。但是当我使用Pjax重新加载表时。一些div会丢失。这是屏幕截图:
这是在提交pjax之前。
提交后的这个
有人知道如何通过pjax重新加载div吗? 谢谢。
这是我提交时的_form代码:
$script = <<< JS
$('form#{$model->formName()}').on('beforeSubmit', function(e)
{
var \$form = $(this);
$.post(
\$form.attr('action'),
\$form.serialize(),
)
.done(function(result){
if (result == 1)
{
$(\$form).trigger('reset');
$.pjax.reload({
container: '#w0',
timeout: false
});
} else {
$('#message').html(result);
}
}).fail(function()
{
console.log('server error');
});
return false;
});
JS;
$this->registerJs($script);
答案 0 :(得分:2)
当您将 <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:text="Hello"
android:background="@color/colorPrimary"
android:layout_width="wrap_content"
android:layout_height="40dp"/>
<TextView
android:text="world"
android:background="@color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="40dp"/>
</LinearLayout>
用于Pjax
的搜索过滤器并重新加载DataTable
时,将从主容器中删除DataTable插件的初始化。
您应该使用Pjax插件提供的Events,对于当前情况,您可以使用
Pjax
:总是在ajax之后触发,无论 结果。
因此您可以绑定事件以将pjax:complete
脚本重新加载到如下所示的容器上。
DataTable
希望有帮助。