fancybox icon indicating copy to clipboard operation
fancybox copied to clipboard

How to work wordpress ajax with fancybox 3?

Open presslayouts opened this issue 9 years ago • 2 comments

How to use below code in fancybox 3? Please give me guide

$(document).on('click', '.quickview', function(e) {
		 e.preventDefault();
		 var pid = $(this).attr('data-product_id');
		 $.fancybox({
			href : myAjax.ajaxurl + '?action=fan_product_quickview&pid=' + pid,
			type : 'ajax',
			helpers : {
				overlay: {
					locked: true

				}
			},
			error    : '<p class="fancybox-error"></p>',
			autoSize: false,
			autoWidth : false,
			afterShow : function() {
				$('.flex-control-thumbs').owlCarousel({
					loop: true,
					responsiveClass: true,
					responsiveRefreshRate : 10,
					rtl : fan_rtl,
					nav: true,
					navText: ['',''],
					dots:false,
					items: 3,					
					
				});				
			},
		
		});
		return false;
	});

Thank you in Advance !!!

presslayouts avatar Apr 19 '17 11:04 presslayouts

Hi,

Most of options you have used do not exist in v3 and it would probably look like this:

$(document).on('click', '.quickview', function(e) {
	e.preventDefault();
	var pid = $(this).attr('data-product_id');

	$.fancybox.open({
		src  : myAjax.ajaxurl + '?action=fan_product_quickview&pid=' + pid,
		type : 'ajax',
		opts : {
			onComplete : function() {
				$('.flex-control-thumbs').owlCarousel({
					loop: true,
					responsiveClass: true,
					responsiveRefreshRate : 10,
					rtl : fan_rtl,
					nav: true,
					navText: ['',''],
					dots:false,
					items: 3,					
				});	
			}
		}

	});

	return false;
});

fancyapps avatar Apr 19 '17 12:04 fancyapps

Hello facnyapps,

OOhh very fast support serves, Very good.

Thank you again, Our facancybox popup complete working now, but our full page display in popup. why?

I need to display clickable only one product in popup, but display full page in popup.

We will some mistack in fancybox popup js or html. Please you can see our below html code:

HTML Code: <a class="quickview" href="#" data-product_id="187">Quick View</a>

JS Code:

$(document).on('click', '.quickview', function(e) {
	e.preventDefault();
	var pid = $(this).attr('data-product_id');

	$.fancybox.open({
		src  : myAjax.ajaxurl + '?action=fan_product_quickview&pid=' + pid,
		type : 'ajax',
		opts : {
			onComplete : function() {
				$('.flex-control-thumbs').owlCarousel({
					loop: true,
					responsiveClass: true,
					responsiveRefreshRate : 10,
					rtl : fan_rtl,
					nav: true,
					navText: ['',''],
					dots:false,
					items: 3,					
				});	
			}
		}

	});

	return false;
});

Thank you so much for your help !!!

presslayouts avatar Apr 19 '17 12:04 presslayouts