open a fancybox programatically?

Q&A about the latest versions
Post Reply
hfeist
Posts: 25
Joined: Tue Oct 16, 2007 11:21 pm
Contact:

I'm trying to open a fancybox from within a pano2vr panorama. I have a hotspot url trigger: javascript:centeredPopup(17);

In the underlying page I have:

Code: Select all

function centeredPopup(id){
   $.fancybox.open({
     'autoScale': true,
     'transitionIn': 'elastic',
     'transitionOut': 'elastic',
     'speedIn': 500,
     'speedOut': 300,
     'autoDimensions': true,
     'centerOnScroll': true,
     'href' : 'popup.asp?qID='+id;
  });
}

$(document).ready(function(e) {
 $(".fancybox")
  .attr('rel', 'gallery')
  .fancybox({
	type: 'iframe',
	autoSize : false,
	beforeLoad : function() {         
		this.width  =400;  
		this.height =300;
	}
  });
});
Alas no fancybox appears.
hf
Don
Posts: 143
Joined: Thu Mar 07, 2013 2:59 pm
Location: Southern California

Try this hotspot url trigger instead:

Code: Select all

javascript:centeredPopup('17');
hfeist
Posts: 25
Joined: Tue Oct 16, 2007 11:21 pm
Contact:

the solution I ended up with is this

Code: Select all

 function centeredPopup(id){
             $.fancybox.open({
			 type: 'ajax',
             'autoScale': true,
             'transitionIn': 'elastic',
             'transitionOut': 'elastic',
             'speedIn': 500,
             'speedOut': 300,
			 'margin':10,
			 'padding':10,
			 'modal':false,
             'autoDimensions': true,
             'centerOnScroll': true,
             'href' : 'popup.asp?id='+id
            });
        }
            
        $(document).ready(function(e) {
        //alert('started');
            $(".fancybox")
            .attr('rel', 'gallery')
            .fancybox({
                type: 'ajax',
                autoSize : false,
                beforeLoad : function() {         
                    this.width  = parseInt(this.element.data('fancybox-width'));  
                    this.height = parseInt(this.element.data('fancybox-height'));
                }
            });
        });
hf
Post Reply