Hi,
I have a problem with ajaxButton but before I explains it here is what am doing: I click ajaxButton and it opens the CJuiDialog. The dialog have list of users to invite. Each user have his own button named invite that is supposed to send user info on controller. The first part works fine and opens dialog. The buttons in dialog does not work! I have checked with firebug they don’t even send ajax calls to controller. Though my code is using Yii Bootstrap, It does not work with normal ajaxButton (I have tested it). Help is appreciated!
Code to open dialog (the button):
$this->widget('bootstrap.widgets.TbButton',
array(
'label'=>'Invite Buddies',
'icon'=>'envelope',
'buttonType'=>'ajaxButton',
'url'=>CHtml::normalizeUrl(array('/weledi/roundTable/invite')),
'ajaxOptions'=>array(
'live'=>false,
'type'=>'post',
'dataType'=>'json',
'success'=>"function(data)
{
if (data.status == 'failure')
{
$('#invite-dialog div.divForForm').html(data.div);
// Here is the trick: on submit-> once again this function!
//$('#invite-dialog div.divForForm').submit(addTalk);
}
else
{
$('#invite-dialog div.divForForm').html(data.div);
setTimeout(\"$('#invite-dialog').dialog('close') \",3000);
}
} ",
),
'htmlOptions'=>array('onclick'=>"$('#invite-dialog').dialog('open');",)
));
code that loads users
<?php
$this->widget('bootstrap.widgets.TbListView',array(
'dataProvider'=>$dataProvider,
'itemView'=>'_inviteFriends',
));
?>
the _inviteFriends.php
<?php
echo '<table>';
echo '<tr><td>'.$data->first_name.' '.$data->last_name.'</td> ';
echo '<td>';
$this->widget('bootstrap.widgets.TbButton',
array(
'label'=>'Invite ',
'icon'=>'ok',
'url'=>$this->createUrl('/weledi/roundTable111/invite'),
'buttonType'=>'ajaxButton',
'ajaxOptions'=>array(
'type'=>'POST',
'dataType'=>'json',
'data'=> "js:{user:$data->user_id, table:'1'}",
'success'=>"function(data)
{
if (data.status == 'failure')
{
$('#invite-dialog div.divForForm').html(data.div);
// Here is the trick: on submit-> once again this function!
//$('#invite-dialog div.divForForm').submit(addTalk);
}
else
{
$('#invite-dialog div.divForForm').html(data.div);
setTimeout(\"$('#invite-dialog').dialog('close') \",3000);
}
} ",
),
'htmlOptions'=>array(
'id'=>'invite-user-'.uniqid(),
'onclick'=>"{alert('Hey I work!');}",
)
));
echo '</td>';
echo ' </tr>';
echo '</table>';