I have an admin page that I am trying to alert the id of an element in the row of the CGridView when selected. I keep getting the following error:
Everything was produced by gii except the javascript
Here is my code:
<script type="text/javascript">
jQuery('#inventory-grid').yiiGridView({
'selectionChanged':$.fn.yiiGridView.getSelection(id) { alert(id); }
});
</script>
<?php
/* @var $this InventoryController */
/* @var $model Inventory */
$this->breadcrumbs=array(
'Inventories'=>array('index'),
'Manage',
);
$this->menu=array(
array('label'=>'List Inventory', 'url'=>array('index')),
array('label'=>'Create Inventory', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#inventory-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Manage Inventories</h1>
<p>
You may optionally enter a comparison operator (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'inventory-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'ID',
'Name',
/*
'CreatedBy',
'ModifiedDateTime',
'ModifiedBy',
'IsDeleted',
'MacAddress',
'SerialNumber',
*/
array(
'class'=>'CButtonColumn',
),
),
));
/*
* jQuery('#inventory-grid').yiiGridView(
* {'ajaxUpdate':['inventory-grid'],
* 'ajaxVar':'ajax',
* 'pagerClass':'pager',
* 'loadingClass':'grid-view-loading',
* 'filterClass':'filters',
* 'tableClass':'items',
* 'selectableRows':1,
* 'enableHistory':false,
* 'updateSelector':'{page}, {sort}',
* 'filterSelector':'{filter}',
* 'pageVar':'Inventory_page',
* 'selectionChanged':$.fn.yiiGridView.getSelection(id) { alert(id); }
* }
* );
*/
?>