WordPress.org

Ready to get started?Download WordPress

Forums

Easy FancyBox
[resolved] About that AJAX issue... (10 posts)

  1. jmartin01
    Member
    Posted 1 year ago #

    Hi Ravan -

    I found this comment you posted on another question, and I think this is the key to my problem - though I couldn't seem to find the actual work-around anywhere for actually dealing with it. Do you think you could clue me in on the 'rescan document for media links' part? I do have an event triggered after...(if I'm wrong, I'll just find a way to add one):

    "Hi, if your theme is loading content (media links) through AJAX, you'll have a problem. FancyBox searches for media and binds itself to the links upon 'document ready' and all content loaded after that event will not be treated.

    Do you know it your theme triggers an event after each new content has loaded? If there is an event triggered, then it could be used to fire a rescan of the document for media links..."

    Here's a link to where fancybox should work on pictures:http://www.davidandersenpianos.com/pianos-for-sale
    (CLICK ON PEARL RIVER GRAND LINK IN NAV ON THE LEFT-SIDE OF THE CONTENT)

    ALSO - fancybox is employed for iframe/pdf/google-viewer links on this page:http://www.davidandersenpianos.com/press Should work for the "read more" links after the excerpts.

    Thank you!!
    Jena

    http://wordpress.org/extend/plugins/easy-fancybox/

  2. RavanH
    Member
    Plugin Author

    Posted 1 year ago #

    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...

  3. jmartin01
    Member
    Posted 1 year ago #

    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!

  4. RavanH
    Member
    Plugin Author

    Posted 1 year ago #

    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 :)

  5. RavanH
    Member
    Plugin Author

    Posted 1 year ago #

    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 :)

  6. jmartin01
    Member
    Posted 1 year ago #

    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

  7. RavanH
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Jena, thanks for sharing. I take it you are you using a pre 1.7 jQuery version. Why?

  8. jmartin01
    Member
    Posted 1 year ago #

    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

  9. RavanH
    Member
    Plugin Author

    Posted 1 year ago #

    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 :)

  10. arslaan ejaz
    Member
    Posted 1 year ago #

    at-least it worked for me.
    After ajax call i called

    easy_fancybox_handler();

    in ajax content page.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic