Cgridview Button Column Ignore Live Htmloption


$colButtons['update'] =  array(

				'url' => null,

				'click' => "function() {

					alert('click');

					return false;

					}",

				'htmlOptions'=>array(

					'live'=>false 

				)

			);

then when grid ajax loaded multiple times in modal dialog, update button make duplicated requests.

in framework/zii/widgets/grid/CButtonColumn I see




protected function registerClientScript()

	{

		$js=array();

		foreach($this->buttons as $id=>$button)

		{

			if(isset($button['click']))

			{

				$function=CJavaScript::encode($button['click']);

				$class=preg_replace('/\s+/','.',$button['options']['class']);

				$js[]="jQuery(document).on('click','#{$this->grid->id} a.{$class}',$function);";

			}

		}


		if($js!==array())

			Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$this->id, implode("\n",$js));

	}

it is always use (document).on … and ignore live parameter ??

Hi,

Try this… hope it will not make multiple request…

When multiple requests triggered means…it is because of jquery file loading multiple times… avoid loading js multiple times… that will solve your problems…

To avoid duplicate js files

     Yii::app()->clientScript->scriptMap=array("jquery.js"=>false, 'duplicatedScrip.js'=>false);

This button code remove live=false…try this

‘buttons’=>array

		(


			'update' => array


			(


				'imageUrl'=>Yii::app()->baseUrl . '/images/' . 'copy.png',


				'visible'=>true,


				'url'=>'$this->grid->controller->createUrl("copy", array("id"=>$data->primaryKey))',


				'options'=>array('style'=>'width:10px; border:none','title'=>'Kopie'),


				'click'=>'function(){


	                        }',


			),

[size=2] [/size][size=2]),[/size]