In my web application I need to implement a dialog box for edit button using javascript and ajax. My code works fine for ajax but i want to display dialog box for editing records. My code
$this->widget ( 'zii.widgets.grid.CGridView', array (
'id' => 'store-grid',
// 'itemsCssClass' => 'table-bordered items',
'dataProvider' => $model->search (),
'filter' => $model,
'columns' => array(
'id',
'store_name',
'is_deleted',
array(
'class' =>'CButtonColumn',
'class'=>'CButtonColumn',
'deleteConfirmation'=>"js:'Do you really want to delete record with Store name '+$(this).parent().parent().children(':nth-child(2)').text()+'?'",
'template'=> '{view}{update}{delete}',
'buttons'=>array
(
'view'=>
array(
'options'=>array(
'ajax' =>array(
'type' =>'POST',
'url' => "js:$(this).attr('href')",
'update' => '#id_view',
),
),
),
'update'=> array
(
'options' =>array(
'ajax' =>array(
'type' =>'POST' ,
'url' =>"js:$(this).attr('href')",
'click' =>"function(){alert("js:$(this).attr('href')"}",
'update'=>'#id_view',
),
),
),
),
),
),
)
);
?>
<div id="id_view"></div>
I am getting error if i use the click function and then give the url inside the 'alert' function.Is there any way in which I can give the details of the object using "($this)" in the javascript function properly. Any body help me with this I am unable to proceed. I am getting error for this line of code
'click' =>"function(){alert("js:$(this).attr('href')"}",
How should I implement this using javascript? This is the html output of the widget
<div class="span-19">
<div id="content">
<ul class="breadcrumb"><li><a href="/stores2/"><i class="icon-home"></i></a><span class="divider">/</span></li><li><a href="#">manage</a><span class="divider">/</span></li><li><a href="index">Stores</a><span class="divider">/</span></li></ul>
<div id="dialogUpdatestore">
<div class="divStore"></div>
</div>
change
'click' =>"function(){alert("js:$(this).attr('href')"}",
to
'click' =>"js:function(){alert("$(this).attr('href')"}",
or this not sure :D
'click' =>"function(){alert("$(this).attr('href')"}",
I think you may be getting your quote marks mixed up. Try changing it to this:
'click' =>"function(){alert($(this).attr('href')}",