Yii-loading the rendering view using ajax in Fancybox

Source: Internet
Author: User
Sometimes we need to render a view in Fancybox.

Sometimes we need to render a view in Fancybox.

This technical guide describes how to implement it.

Step 1: Prepare the View File
 widget('application.modules.admin.extensions.fancybox.EFancyBox', array()); //create an ajax link which will call fancybox AFTER the ajax call completes echo CHtml::ajaxLink('NameOfLink',Yii::app()->createUrl('fancy'),array('type'=>'POST', 'update'=>'#preview', 'complete'=>'afterAjax')); ?> //add the div which will hold our ajax response 
 
 
Step 2: implement the controller method to return this view
public function actionFancy(){ Yii::app()->clientScript->scriptMap['*.js'] = false; $this->render('view',array('value'=>'data')); }
Step 3: implement the js method and trigger Fancybox after ajax update
function afterAjax() { $.fancybox({ href : '#preview', scrolling : 'no', transitionIn : 'fade', transitionOut : 'fade', //check the fancybox api for additonal config to add here  onClosed: function() { $('#preview').html(''); }, //empty the preview div }); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.