我正在尝试为bootstarp.widgets.TbButtonColumn
配置bootstrap.widgets.TbExtendedGridView
,我已经在他们的official网站上使用了教程。但是,我收到以下错误Uncaught TypeError: Cannot read property 'addClass' of null at bootstrap-editable.js:1098
。我很难弄清楚错误的根本原因。任何帮助与高度赞赏。我使用以下代码
<?php $this->widget('bootstrap.widgets.TbExtendedGridView', array(
'id'=>'brands-data-table',
'dataProvider'=>$model->search(),
'pagerCssClass'=>'dataTables_paginate paging_bootstrap pagination',
'template'=>'{items}{summary} {pager}',
'summaryCssClass'=>'dataTables_info',
'pager'=>array("htmlOptions"=>array('class'=>"pagination"),'hiddenPageCssClass'=>'disabled','header'=>'','selectedPageCssClass'=>'active'),
'columns'=>array(
array (
'name'=>'name', //
'value'=>'$data->name',
'filter'=>false,
'class' => 'bootstrap.widgets.TbEditableColumn',
'headerHtmlOptions' => array('style' => 'width:200px'),
'editable' => array(
'type' => 'text',
'url' => '/example/editable',
'placement' => 'right',
'inputclass' => 'span3'
)
),
),
'itemsCssClass'=>'table table-striped table-bordered table-hover',
'htmlOptions'=>array(
'class'=>'',
),
)); ?>
js code
$('#brands-data-table a[rel^=ProductBrand_name]').editable([]);
$("#brands-data-table").parent().on("ajaxUpdate.yiiGridView", "#brands-data-table", function() {$('#brands-data-table a[rel^=ProductBrand_name]').editable([]);});
jQuery('#brands-data-table').yiiGridView({'ajaxUpdate':['brands-data-table'],'ajaxVar':'ajax','pagerClass':'dataTables_paginate paging_bootstrap pagination','loadingClass':'grid-view-loading','filterClass':'filters','tableClass':'table table-striped table-bordered table-hover table','selectableRows':1,'enableHistory':false,'updateSelector':'{page}, {sort}','filterSelector':'{filter}','pageVar':'ProductBrand_page','afterAjaxUpdate': function(id, data) {
$("#"+id).trigger("ajaxUpdate.yiiGridView");
}});
$grid = $("#brands-data-table");
if ($(".extended-summary", $grid).length)
{
$(".extended-summary", $grid).html($("#brands-data-table-extended-summary", $grid).html());
}
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {
var qs = $.deparam.querystring(options.url);
if (qs.hasOwnProperty("ajax") && qs.ajax == "brands-data-table")
{
if (typeof (options.realsuccess) == "undefined" || options.realsuccess !== options.success)
{
options.realsuccess = options.success;
options.success = function(data)
{
if (options.realsuccess) {
options.realsuccess(data);
var $data = $("<div>" + data + "</div>");
// we need to get the grid again... as it has been updated
if ($(".extended-summary", $("#brands-data-table")))
{
$(".extended-summary", $("#brands-data-table")).html($("#brands-data-table-extended-summary", $data).html());
}
}
}
}
}
});
});
interal js code
this.$element.addClass('editable-open');
if(closeAll !== false) {
//close all open containers (except this)
this.closeOthers(this.$element[0]);
}
//show container itself
this.innerShow();
this.tip().addClass(this.containerClass);