Hi Jena, yes, it looks like you’re facing the ajax issue. Can the theme developer tell you if there is a javascript event triggered after new content has been loaded? If so, that could be used to fire fancybox (again) but if not, there is no way to get it working at this point I’m afraid…
Yes, there is an event triggered after the new content is loaded (I’m the theme developer along with my buddy here who did the javascript).
Is there just a snippet we can run in our last event to fire fancybox again?
Thanks for your response!
There are two ways, both need the development version of Easy FancyBox: http://downloads.wordpress.org/plugin/easy-fancybox.zip
That version has a function handle called easy_fancybox_handler
that is used in
<script type="text/javascript">
jQuery(document).on('ready gform_post_render', easy_fancybox_handler );
</script>
One method could be to add the event name that is triggered after new content has loaded to the list 'ready gform_post_render'
(gform_post_render is an event by gforms) by modifying the easy-fancybox-class.php file on line 497.
Another method could be modifying the theme and you seem to be just the person to do that 😉 You can use the handle easy_fancybox_handler to launch the complete script again whenever you need to 🙂
Note: be aware that if you try to call easy_fancybox_handler when the Easy FancyBox plugin is not installed or deactivated, an Undefined variable exception error will be thrown so you need to do a if(typeof easy_fancybox_handler == 'function')
check before calling it.
Alternatively, you could trigger an event called gform_post_render upon each new content. Maybe that’s the easiest 🙂
Ravan,
Thank you thank you thank you.
We tried your last method (triggering the event gform_post_render upon new content loading in the theme’s script) – and it didn’t work at first – we realized there was an error in the console saying that ‘Object#<Object> has no method on’ and it was referring to the very line in the fancybox plugin that you mention above (line 497 of the easy-fancybox-class.php file).
To get it to work, we kept with your last method and in line 497 in easy-fancybox-class.php we actually changed ‘on’ to ‘bind’ and the error went away and it works!
I really appreciate your responsiveness and help.
Cheers!
Jena
Hi Jena, thanks for sharing. I take it you are you using a pre 1.7 jQuery version. Why?
Ravan,
Thanks for pointing this out. 🙂
It was accidental – I started with a blank theme template that’s a bit old, and I had thought it was set up in the functions.php to load the latest version (I’m just ‘enque-ing’ this script in my header) but apparently I had it loading a particular (old, of course) version of jquery!
So by the directness of your question, I suppose your plugin file that I had to edit would work just fine on a current version of jquery..?
Also, I’d like to donate to the plugin and I tried, but was a little confused (not sure if I was really in the right place, and had a little trouble trying to pay), can you give me the correct link to do so?
Thanks,
Jena
Hi Jena, Yes it should work with any jQuery version 1.7+ so the one included with an up to date WordPress installation should be just fine. 🙂
By the way, you do not need to enqueue jQuery separately. If you enqueue any script file (in your functions.php or header.php) that needs the jQuery library, just mark it as a dependency. It’s the $deps parameter on http://codex.wordpress.org/Function_Reference/wp_enqueue_script. After that, WordPress will manage when to include the what.
Also, I’d like to donate to the plugin
Your contribution will be highly appreciated! As with any plugin in the WordPress plugin directory, there’s a “Donate to this plugin” link on the plugin page. If you go to http://wordpress.org/extend/plugins/easy-fancybox/ you’ll see it on the right. Thanks 🙂
at-least it worked for me.
After ajax call i called
easy_fancybox_handler();
in ajax content page.