Ajax form submit to fancybox.

107 views
Skip to first unread message

Tank

unread,
Jun 15, 2009, 5:13:17 PM6/15/09
to fancybox
I want to submit a form and load the returned information into the
fancybox window.

Here is how i have set it up;
i have a hidden DIV, on the page with an image inside that just says
"sending information",
when submitted, the form will call fancybox and then send/return the
data.
fancybox needs to come up and say "sending information" for a moment,
then display the returned data

I can get either the ajax to work, or fancybox, but not both.

I used an <a href="#somediv"> which displays my div, but i cannot get
the ajax to submit off using link. (and stay on the same page, even
with return false)

Trying an <input type="image"> gets the ajax to submit, but i cannot
load my div into fancybox.

is there a way to call fancybox for a given element through
javascript?

I want to call it from my form submit ajax function thingy.

it would be nice if i could do something like:
fancybox('#mydiv');

Tank

unread,
Jun 15, 2009, 5:42:33 PM6/15/09
to fancybox
ok i found something that kind of works.

$("#getFancy").fancybox();

then to activate it with jQuery

$("#getFancy").click();

but doing this navigates me away from the page, even though the link
is :
<a href="#mydiv" style="display:none;" id="#getFancy">.</a>

Tank

unread,
Jun 15, 2009, 6:33:34 PM6/15/09
to fancybox
The .click() method works, but it does not update the content in the
box. If you close and click it again, the content will be changed
though.
I need to figure out how to update the content once the fancybox is
activated.

Tank

unread,
Jun 15, 2009, 7:05:54 PM6/15/09
to fancybox
ok I got it,
after the data in the DIV is updated with the returned data, i did a
second $("#getFancy").click(); and it works like a charm.

On Jun 15, 5:42 pm, Tank <dreadxpir...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages