Rafael Sedrakyan Rafael Sedrakyan - 9 months ago 39
PHP Question

Fire off alerts on button click

When I click the button, alerts aren't performed. What am I doing wrong? Maybe I need to include some js files in my header section?

Here is my login form view:

<?php echo CHtml::beginForm(); ?>

<div class="row">
<?php echo CHtml::label('username', 'username'); ?>
<?php echo CHtml::textField('username'); ?>
<div class="row">
<?php echo CHtml::label('password', 'password'); ?>
<?php echo CHtml::textField('password'); ?>
echo CHtml::ajaxButton('sign in', array('site/login'),array(
'beforeSend' => 'function(){
'complete' => 'function(){

<?php echo CHtml::endForm(); ?>
<div id="mydiv" style="color:white;">...</div>

Here is my code in the controller:

public function actionLogin()

user_info just echoes
some text

Answer Source

Not sure if this is your problem, but renderPartial() does not play well with AJAX. It is a known Yii issue:

http://www.yiiframework.com/forum/index.php/topic/24699-yii-20-ajaxrenderpartial-conflict/ http://www.yiiframework.com/forum/index.php?/topic/10427-ajax-clientscript

I ran into the problem when I tried to load a form via AJAX, then submit it back using CHtml::ajaxSubmitButton.