Changes
Title
unchanged
CJuiDialog and AjaxSubmitButton
Category
unchanged
Tutorials
Yii version
unchanged
Tags
changed
AJAX
Content
changed
[...]
The ajaxLink will call an action in the JobController with name ActionAddnew ( we will call it Addnew from now on ), which will either save the job ( after validation ) either rendering the job form.
###3. _FormDialog:
Finally, the job form which consist of a create.php view and a _formDialog.php view, both exist under under job/views/.
The _formDialog.php ( we will call it _formDialog from now on ) will contain an ajaxSubmitButton to submit the Job we want to create.
##Code and details
Now, I don't know from where exactly I should
i start to make it
more easyeasier for you.
I assume you have a little experience with ajaxLink etc
al., though
iI will try to be as
much detailed as
iI can.
### _form. The person's create form.[...]
and finally last but not least the `$htmlOption` where I set an `id` to the `ajaxLink` for avoiding some issues.
### JobController. The ActionAddnew.
~
```php[...]
}
if($flag) {
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
$this->renderPartial('createDialog',array('model'=>$model,),false,true);
}
}
```~
####Where to pay attention:
I think thisThe scriptMap parameter is essential. Without that line, jquery.js will be loaded again and can cause issues with javascript both already existing on the page, as well as duplicated event handlers for ajax calls run multiple times that contain their own javascript. You may want to use scriptMap to prevent other js files from loading again using '*.js' as the array key.
I think the rest is straightforward. Pay attention the last 2 parameters of [renderPartial](http://www.yiiframework.com/doc/api/CController#renderPartial-detail)
We call first the `createDialog.php` from `job/views/` which is the following.[...]
'options'=>array(
'title'=>Yii::t('job','Create Job'),
'autoOpen'=>falstrue,
'modal'=>'true',
'width'=>'auto',
'height'=>'auto',
),
));[...]