2014-05-17 38 views
0

我收到錯誤
Uncaught TypeError: undefined is not a function jquery.yiigridview.jscgridview中的ajaxlink;錯誤未定義是不是在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'); 
           } 

回答

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=====*/ 
        ); 
       } 
      })), 
)); 
?> 
+0

哦,我感覺很傻。謝謝! – JamAndJammies

+0

其實我仍然有這個問題。未定義不是一個函數。它發送數據,但yiigridview無法刷新該錯誤。 – JamAndJammies