Yii2 kartik-v gridview: TypeError: jQuery(...).editable is not a function
Yii2 kartik-v gridview: TypeError: jQuery(...).editable is not a function
当第一次将第一个新数据插入 gridview 时(此时 gridview 中没有来自数据库的数据),所有可编辑列都显示为故障按钮而不是工作 link。刷新页面后,Gridview 中的可编辑列按预期显示为 link 并且正常工作。
为什么只有第一次出现这个问题?
这是将第一个新数据插入 Gridview 后显示的错误。
TypeError: jQuery(...).editable 不是函数
这是我的专栏:
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'short_desc',
'refreshGrid' => true,
'editableOptions' => function ($model, $key, $index) {
return [
'header'=>'short_desc',
'size'=>'md',
];
}
]
谢谢。
即使在只有一个数据(第一个数据)的 pjax 重新加载之后,我也已经解决了我的代码刷新页面的问题。
在我的 addNewData() 的 jquery 函数中,我在成功添加新数据后重新加载 pjax 后添加了以下代码:
<?php
$models = $dataProvider->getModels(); // get dataProvider to check if there is any data
// refresh whole page for the first newly added data when there is only one data as in Editable Column not initiated when there is no data
if( count($models) < 1 || $models == null || !isset($models) )
{
?>
window.location.reload();
<?php
}
?>
现在这对我有用。
当第一次将第一个新数据插入 gridview 时(此时 gridview 中没有来自数据库的数据),所有可编辑列都显示为故障按钮而不是工作 link。刷新页面后,Gridview 中的可编辑列按预期显示为 link 并且正常工作。
为什么只有第一次出现这个问题?
这是将第一个新数据插入 Gridview 后显示的错误。
TypeError: jQuery(...).editable 不是函数
这是我的专栏:
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'short_desc',
'refreshGrid' => true,
'editableOptions' => function ($model, $key, $index) {
return [
'header'=>'short_desc',
'size'=>'md',
];
}
]
谢谢。
即使在只有一个数据(第一个数据)的 pjax 重新加载之后,我也已经解决了我的代码刷新页面的问题。
在我的 addNewData() 的 jquery 函数中,我在成功添加新数据后重新加载 pjax 后添加了以下代码:
<?php
$models = $dataProvider->getModels(); // get dataProvider to check if there is any data
// refresh whole page for the first newly added data when there is only one data as in Editable Column not initiated when there is no data
if( count($models) < 1 || $models == null || !isset($models) )
{
?>
window.location.reload();
<?php
}
?>
现在这对我有用。