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

  • Home
  • SEARCH
  • 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 7756287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:47:04+00:00 2026-06-01T12:47:04+00:00

I am having some trouble setting up FancyBox, I am somewhat new to jQuery.

  • 0

I am having some trouble setting up FancyBox, I am somewhat new to jQuery. I followed their guide, but I don’t see anywhere that I could have gone wrong.

I have linked the .css files and the .js files that I need. I know they are linked properly because if I view the source and click on the /assets/jquery.fancybox.css?body=1 and /assets/jquery.fancybox.css?body=1 I can see the proper Javscript and CSS files.

Because I am using Ruby on Rails I added this line to my application.js file:

$(document).ready(function() {
    $(".fancybox").fancybox();
});

And then just to test I added this into one of my pages, but instead of appearing in FancyBox it just opens the image in a new page:

<a class="fancybox" rel="group" href="http://farm8.staticflickr.com/7171/6417719753_374653e28c_b.jpg"><img src="http://farm8.staticflickr.com/7171/6417719753_374653e28c_m.jpg" alt="" />link</a>

As far as I know, it should be working, I have the class set to “fancybox” and the script looking for an object with a “fancybox” class.

EDIT: I seem to have fixed it by adding

$(document).ready(function() {
    $(".fancybox").fancybox();
});

To the .erb file of a specific page. Why would this not work if added to application.js? Is there a good way to fix this?

  • 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-01T12:47:05+00:00Added an answer on June 1, 2026 at 12:47 pm

    I would guess that your application.js file is being loaded before the jQuery source, and hence $ isn’t available yet.

    Be sure to check your browser’s console for errors in these situations – it can save you a lot of headaches.

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

Sidebar

Related Questions

I have a script which successfully creates new nodes. But I'm having trouble setting
I'm having some trouble setting up Apache on Ubuntu. I've been following this guide
I am having some trouble setting up my environment in Eclipse for ImageMagick via
I'm having some trouble setting the ExecutionTimeout element in my applications web.config. My page
I'm having some trouble implementing a fixed table header with CSS and jQuery, though
I am having trouble setting up jpa mappings for some entities. I have a
I'm having some trouble with setting the where clause of the following query: CriteriaBuilder
I've been having some trouble with Snow Leopard's new block-based API for observing notifications
I'm having some trouble setting the quality settings on a video via the Youtube
I'm having some trouble setting up virtual machines for testing IE versions (I use

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.