Reputation: 1465
I really cannot understand what is going on. The Url manager is turned off. What's even more strange is that when I hover over the link, the link path is correct, but when I click on it, inspect element shows a strange link order, and I get 404 error.
on hover: index.php?r=action/controller&id=180"
inspect: index.php?r=action/controller&id=180"
on click: index.php?ajax=grid-id&id=180&r=action/controller
correct one is the hover one. on click is completely wrong and weird. Why is it getting my grid id? I can't understand.
How would it take the grid id and append it in my url? and then use id then action/controller?!
grid:
'value'=>function($data){
if (intval($data->id) ==Yii::app()->user->id){
return CHtml::link("[X]", array("action/controller","id"=>$data->pid), array('confirm' => 'Are you sure? ', 'class'=>'stat-active'));
}
....
Is it something related to this? I have it elsewhere, they seem to work fine.
<?php
Yii::app()->clientScript->registerScript('stat-active', "
$('#grid-id a.stat-active').live('click', function() {
$.fn.yiiGridView.update('grid-id', {
type: 'POST',
url: $(this).attr('href'),
success: function() {
$.fn.yiiGridView.update('grid-id');
}
});
return false;
});"
);
?>
[edit] full grid:
<?php
$this->widget ( 'bootstrap.widgets.TbGridView', array (
'type' => 'striped condensed',
'id'=>'grid-id',
'dataProvider' => $active,
'template' => '{items}{pager}',
'columns' => array (
array (
'name' => 'effective_to_date',
'header' => 'Effective To',
array(
'header'=>'Notes',
'type'=>'raw',
'value'=>'CHtml::link(substr($data->des, 0, 70)."...",
Yii::app()->createUrl("action/controller/details", array("id"=>$data->artid)), array("data-toggle"=>"modal","data-target"=>"#message_modal","content" => "$data->des"))',),
array(
'type'=>'raw',
'value'=>function($data){
if (intval($data->aProd->user_id) ==Yii::app()->user->user_id()){return CHtml::link("[X]", array("action/controller","id"=>$data->aId),array('confirm' => 'Are you sure? ','class'=>'stat-active'));
}
else { if(intval($data->bProd->user_id) ==Yii::app()->user->user_id()){
return CHtml::link("[X]", array("action/controller","id"=>$data->bId),array('confirm' => 'Are you sure? ','class'=>'stat-active')
);
}
}}
),
)));?>
<?php $this->beginWidget(
'bootstrap.widgets.TbModal',
array('id' => 'message_modal',
)); ?>
<script type="text/javascript">
$("a[data-toggle=modal]").click(function(){
var target = $(this).attr('data-target');
var url = $(this).attr('href');
if(url){
$(target).find(".modal-body").load(url);
}
});
</script>
<div class="modal-header" id="messages">
<p style="font-size: 18px">Notes</p>
</div>
<div class="modal-body" id="messages">
<p></p>
</div>
<?php $this->endWidget();?>
Upvotes: 1
Views: 135
Reputation: 591
Here you might have to use url manager. enable your url manager form config/main.php..
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\S+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
this will manage your url like this
index.php/controller/action/180
try this. i hope this will help you
thank you.
Upvotes: 2