0

我收到错误
Uncaught TypeError: undefined is not a function jquery.yiigridview.js

我尝试了几种方法,但我认为我没有正确执行此操作。我目前有:

  $this->widget ( 'bootstrap.widgets.TbGridView', array (
  'type' => 'condensed',
  'id'=>'inq',
  'dataProvider' => $dataProvider,
  'template' => '{items}{pager}',
  'columns' => array (
        array(
        'header'=>'',
        'type'=>'raw',
        'htmlOptions'=>array('style'=>'width:30px'),
        'value'=>function($data,$row){
        if($data->message_target_read == "Read")
        return CHtml::ajaxLink('<img src="'.Yii::app()->baseUrl.'/images/site/star-read.png">',
                  Yii::app()->createUrl("controller/action", array("id"=>$data->id)),
                  array("complete"=>"function(){
                  $.fn.yiiGridView.update('inq', {
                  type: 'POST',
                  url: $(this).attr('href'),
                  success: function() {
                  $.fn.yiiGridView.update('inq');}
                  });return false;}"));

我也尝试过chtml::link使用一个类并获取Yii::app()->clientScript->registerCoreScript('class',但它一直在重定向整个页面。我也试过这样做

CHtml::ajaxLink("<img>",Yii::app()->createUrl("controller/action", array("id"=>$data->id)),array( 
type: 'POST',
url: $(this).attr('href'),
success: function() {
$.fn.yiiGridView.update('inq');
                                }
4

1 回答 1

0

你错过了CHtml::ajaxLink(). 您在自定义 ID 之后关闭了它array("id"=>$data->id))。这可能会导致功能故障。

请检查以下结构。

<?php
$dataProvider = new CActiveDataProvider('FlightSearch');
$this->widget('bootstrap.widgets.TbGridView', 
array(
    'type' => 'striped bordered condensed',
    'id' => 'inq',
    'dataProvider' => $dataProvider,
    'template' => "{items}{pager}",
    'columns' =>
    array
    (
        array('name' => 'column1', 'header' => 'Column Title'),
        array
        (
            'header' => '',
            'type' => 'raw',
            'htmlOptions' => array('style' => 'width:30px'),
            'value' => function($data, $row) 
            {
                if($data->message_target_read == "Read")
                {
                    return CHtml::ajaxLink('a link', 
                    Yii::app()->createUrl("controller/action", 
                    array("id" => $data->id), 
                    array("complete" => "function()
                    { 
                          /*=====Your jQuery functionality start=====*/
                          $.fn.yiiGridView.update('inq', {
                          type: 'POST',
                          url: $(this).attr('href'),
                          success: function() 
                          {
                                $.fn.yiiGridView.update('inq');
                          }
                          });return false;}"))
                          /*=====Your jQuery functionality end=====*/
                    );
                }
            })),
));
?> 
于 2014-05-17T17:42:38.497 回答