This scenario:
The user inserts his zip into an input-field, and when clicking the magic button, he gets to see stores closest to his location. I ca
This is how I done it:
you need three elements:
1)you need a div that serves as container for the fancybox, let's call it #fancycontainer
2)#fancylink is a hidden with href to the fancybox div(in this case
href="#fancycontainer"
)
3)#button is the clickable element which loads everything.
Add the following code in the onload function:
$('#fancynlink').fancybox();
$('#button').click(function(){
$.ajax({
//OPTIONS...
//..........
success: function(data){
//Here goes the code that fills the fancybox div
$('#fancycontainer').append(blablabla.....);
//And this launches the fancybox after everything has loaded
$('#fancylink').trigger('click');
}
});
Hope this helps someone