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 6210905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:14:38+00:00 2026-05-24T06:14:38+00:00

I have two links to open a fancy box. One is on the page

  • 0

I have two links to open a fancy box.

One is on the page when the page loads.
The other I inject onto the page with Ajax after performing some action.

Both links are identical.
The one that is on the page when the page loads opens the fancybox when it is clicked.

The one that is injected with Ajax does not.

Here is the jquery script for the fancybox in the application.js file.

$(document).ready(function() {
    $("a.iframe`").fancybox({
        'hideOnContentClick': true,
        'hideOnOverlayClick': true,
        'padding'           :   0 ,
            'width'         :   600 ,
            'height'        :   500,
            'transitionIn'  :   'elastic',
            'transitionOut' :   'elastic',
            'speedIn'       :   200, 
            'speedOut'      :   200,
    });
});

Here is the link that opens the fancybox and is on the page at page load:

<a class="iframe" href="/icons?id=5&upload_for=Greeting">change</a>

Here is the link that does not work to open the fancy box that I put on the page using ajax:

<a class="iframe" href="/icons?id=30&upload_for=Greeting">change</a>

Why does one link work and not the other

  • 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-05-24T06:14:39+00:00Added an answer on May 24, 2026 at 6:14 am

    When you call $('a.iframe').fancybox(...), it only applies to the elements already on the page and won’t automatically apply to future elements via ajax.

    If you’re using something like a .js.erb file to insert the link dynamically, you could add another call to .fancybox(...) in there.

    Or, you could use something like the Live Query plugin. This will let you do something like this, and it will automatically apply to all future items:

    $('a.iframe').livequery(function(){ 
      $(this).fancybox({
        'hideOnContentClick': true,
        'hideOnOverlayClick': true,
        'padding'           :   0 ,
            'width'         :   600 ,
            'height'        :   500,
            'transitionIn'  :   'elastic',
            'transitionOut' :   'elastic',
            'speedIn'       :   200, 
            'speedOut'      :   200,
      }); 
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two links, one with id #calendar_arrival_open and another with #calendar_departure_open. Both links
I have two links I use for sorting. One by Make and one by
lets say i have two pages links.html & contents.php ... first page contains only
I have a page with several links that open a separate window with varying
I have two links on an optimized mobile Safari web site. One is a
In my html page, I have two links located on the top of the
i have a lotus application and have a page which has two links on
I have two links with classes (login-form and register-form) relevant to their target forms
I have the following two links in my main menu, and I have some
For technical reasons on a site we may have two or more links that

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.