Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9220327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:19:15+00:00 2026-06-18T03:19:15+00:00

I’m having trouble getting fancybox to trigger. I have it set up to trigger

  • 0

I’m having trouble getting fancybox to trigger. I have it set up to trigger when you click an element. I still don’t know why, but for some reason fancybox only works if i bind it using live(), sort of like this:

$(document).ready(function() {
    // This works
    $('.fancybox').live('mousedown', function() {
        $(this).fancybox();
    });

    // This doesn't
    $('.fancybox').fancybox();
});

Read more about that here:
Fancybox is loaded, but nothing happens, and no errors?

The problem is, it only works if i actually click the element. If i try to trigger a click using:

$('.fancybox').trigger('mousedown');

i get nothing! It just doesn’t work.

The reason i need to do this is because the images are being printed out with PHP in a gallery (with thumbnails etc). I only want a dropdown of the available galleries, so on page load, i hide all of the thumbnails and then loop through them and create a dropdown menu containing all the galleries. So far so good! If i show the element using the inspector (using chrome) and then manually click on it, it works fine! Although, the problem is, when i try to trigger the click using the dropdown, nothing happens!

I have it set up so that every <option> in the dropdown has a data attribute of the gallery/thumbnail ID, and when the dropdown changes (when you select an option), it automatically finds the correct image, and triggers a click – which in turn should open a fancybox. I know it finds the correct image, and clicks it, it’s just that nothing happens when it’s clicked.

Try it!

URL: http://goo.gl/r4Klf

Rightclick on the first dropdown menu in the content, and inspect it. Above it, you’ll see a bunch of .ngg-galleryoverview elements. Click on one of them and remove all the styling applied to the element (in element.style, the style basically hides the element). Then expand the element, and in there you’ll see a .ngg-gallery-thumbnail. Remove display: none from the styling. You should now be able to see the element on the page. If you try clicking it, the fancybox will open. However, if you try to click it using $(the element).trigger('mousedown'), it’s not going to work. Try targeting it using the href attribute, something like:

jQuery('a[href="http://hallarna.se/wp-content/gallery/2013/spoksonatenloggaliten.jpg"]').trigger('mousedown');

Please do note that jQuery is in noConflict mode meaning you will have to use jQuery() instead of $().

I’ve been battling this for several days now. Any ideas are super appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:19:16+00:00Added an answer on June 18, 2026 at 3:19 am

    I think I see where the problem is. When you trigger mousedown, it just fires the plugin to work with the specified element when you click it; it’s not actually supposed to show anything… until you click it or you trigger the click.

    Try something like

    jQuery('a[href="http://hallarna.se/wp-content/gallery/2013/spoksonatenloggaliten.jpg"]').trigger('mousedown').trigger('click');
    

    Although I would look for a solution to make fancybox work as intended, with $(‘.fancybox’).fancybox();

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.