简体   繁体   中英

Fancybox not working after submitting the parent page

I have two buttons in a page. one for Submitting the page and one for Fancybox. After clicking the Submit button Fancybox is not working. I am using YII model validation on submit button click.

My facybox js is:

 $(function(){
$(".various3").fancybox({
'width'             : '75.65%',
'height'            : '100%',
'top'               : '-1020',
'autoScale'         : false,
'autoDimensions'                : false,
'scrolling'                     :'No',
'transitionIn'                  : 'none',
'transitionOut'                 : 'none',
'type'              : 'iframe',
'padding'                       : 0,
'margin'                        : 0,
'onComplete'                    : function(){$('.fancybox-iframe').contents().find('#MerchantLocations_location_name').focus();}
    });

});

This is my view:

<a href="<?php echo Yii::app()->createAbsoluteUrl('/admin/addlocation/');?>" class="various3 " ><input type="button" class="big-btns-small floatright" value="Add Location"/></a>

also at error console of Mozilla "Error: TypeError: t is undefined" is appearing

If you're working with Yii grids and their search functionality it is very likely that in the response of a ie search query you get jQuery delivered again in the AJAX response. Then the reinitialization of jQuery breaks your existing FancyBox widget.

The quick workaround is to disable jQuery in the scriptMap section of your clientScript component, see this question for details: How to disable jQuery autoloading on Ajax request in Yii?

Finally fixed......

Am updated the fancy box to latest version 2.1.4 from 1.3.4

Now what happen is the popup is coming . But div with class 'fancybox-overlay' is coming 2 times . ie first one with popup content and a another with blank(no content). Since the blank div is coming over the other one.The popup immediately close when i click over popup.

To overcome this the including of fancybox script and style sheet moved to header part of the site(it to view/layout/main.php).

Thanks @schmunk for your valuable time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM