tags:

views:

358

answers:

2

I just started learning AJAX and Yiiframework. What are the steps to create AJAX login form in Yii?

Thank you.

+1  A: 

Try the following in your view, where the login button is

<?php echo CHtml::ajaxButton('Add Course', array('student_Courses/Create'),array(
        'type'=>'POST',
        'update'=>'#resultStudentCourse',
        'beforeSend' => 'function(){
            $("#resultStudentCourse").addClass("loading");
        }',
        'complete' => 'function(){
            $("#resultStudentCourse").removeClass("loading");
            }',

)); ?>

#resultStudentCourse is the ID of the DIV where you need to load in your message, EG. Successfully logged-in

Then in your controller the create method have something like this

if(Yii::app()->request->isAjaxRequest){
$this->renderPatial('create',array('model'=>$model));
}

Hope this helps

Roland
A: 
    if(Yii::app()->request->isAjaxRequest){
$this->renderPatial('create',array('model'=>$model));
}

For the sake of real clarity (as not too many folks are using this framework quite yet) the above should be

$this->renderPartial
fred