?
Solved

Automatically call jquery function (fancybox) when page loads

Posted on 2012-08-30
6
Medium Priority
?
1,070 Views
Last Modified: 2012-09-17
Experts,

Im having difficulty trying to get a fancybox function to start when the page loads. I have reviewed the guides on the host website but cant get it to work...

http://www.suremedia.co.uk/aegis.php
(as you can see i have tried simulating the click event but it doesnt initiate the function)

Any suggestions would be greatly appreciated

Regards
Easynow
0
Comment
Question by:Dean OBrien
  • 4
  • 2
6 Comments
 
LVL 9

Accepted Solution

by:
WebDevEM earned 2000 total points
ID: 38350225
Hi... I have a JSFiddle set up for that at http://jsfiddle.net/webdevem/5EV8r/ if you want to take a look.  What I did was create a link with no content (so it can't be seen) and simulate the click on that.

<a class="fancyTrigger" href="#TheFancybox"></a>
<hr>
<div id="TheFancybox"></div>

Powered by <a href="http://fancybox.net/" target="_blank">Fancybox</a>
¿

$(".fancyTrigger").fancybox();
$(".fancyTrigger").trigger('click');¿

Open in new window

0
 
LVL 12

Author Comment

by:Dean OBrien
ID: 38350245
Hi Webdevem

I have tried that but for some reason its not working. Can you see whats wrong with the following?

<a href="#inline" class="various yellow" id="form-caller">here</a>

$(document).ready(function() {
	$(".various").fancybox({
		maxWidth	: 900,
		maxHeight	: 900,
		fitToView	: true,
		width		: '50%',
		height		: '50%',
		autoSize	: true,
		closeClick	: false,
		openEffect	: 'none',
		closeEffect	: 'none'
	});


});
$(".various").trigger('click');

Open in new window


Thanks
Easynow
0
 
LVL 12

Author Comment

by:Dean OBrien
ID: 38350262
never mind that, i had the trigger function out side the ready function...

Im sure i might have looked at your jsFiddle when messing earlier...

Thanks
Easynow
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:WebDevEM
ID: 38350340
I just found that site recently, and love it for testing things out... I even post examples on code I post on my jQuery blog.  (Still in its infancy, but it's a good start.  http://juntangled.blogspot.com/)

So everything's working now?
0
 
LVL 12

Author Comment

by:Dean OBrien
ID: 38350459
Yeh its working now.

The auto start was in fact for the page that is displayed after the form is sent. Otherwise the success/fail message was not being show to the user.

Thanks for help

Easynow
0
 
LVL 12

Author Closing Comment

by:Dean OBrien
ID: 38404987
Sorry for delay
Easynow
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month15 days, 22 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question