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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:40:13+00:00 2026-05-30T11:40:13+00:00

i coded a nice galery, where the clicked pictures are overlayed over the whole

  • 0

i coded a nice galery, where the clicked pictures are overlayed over the whole webpage.
The Problem is, all the pictures and thumbnails are loaded immidiatly, i want the large pictures only to be loaded, when womebody presses the corresponding thumnail.
I have no ajax experience, though i tried to do something with :remote => true, which didnt work out. Can somebody help?

<% for painting in @gallery.paintings %>
  <div class="painting">
  <%= image_tag painting.image_url(:thumb), :remote => true, :rel => "##{painting.id}" %>

    <div class="overlay" id="<%= painting.id %>" >
      <%= image_tag painting.image_url %>
    </div>
<% end %>

and my javascript coffe-script file

$(document).ready ->
  $("img[rel]").overlay();
  $(".close").click ->
    $("#dim").fadeOut()
    false
  $("div.painting img").click ->
    $("#dim").fadeIn()
    false
  $(".overlay").css "width", $(window).width()
  $("#dim").css "width", $(window).width()

$(window).bind "resize", ->
  $(".overlay").css "width", $(window).width()
  $("#dim").css "width", $(window).width()

EDIT 2012/3/24:

I changed the repo by using:

  gem 'fancybox-rails', :git => 'https://github.com/sverigemeny/fancybox-rails'

Works out of the box and looks awesome.

  • 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-30T11:40:17+00:00Added an answer on May 30, 2026 at 11:40 am

    You don’t need to know ajax to do this because you can just set the source property on an existing image or create an image element. Now if you want to retrieve html or a url or something from your server, then you will need to know ajax. Let us know if that is what you are doing.

    http://jsfiddle.net/mrtsherman/nzdpt/1/

    <button id="a">Create element</button>
    <button id="b">Swap src on img</button>
    <img id="c" src="http://placehold.it/150x150/ff0000" />​
    
    //create a new image element and append it to dom
    $('#a').click(function() {
        var $img = $('<img />', {
                 id: 'foobar ',
                 src : 'http://placehold.it/150x150'
        });
        $('body').append($img);
    });
    
    //get an existing img element and change its source 
    $('#b').click( function() {
        $('#c').prop('src', 'http://placehold.it/100x100');
    });
    ​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a reacurring problem. I code nice standards compliant code only to have
I am looking for a nice code solution for the following problem. I have
SBT has a nice hook which allows you to execute arbitrary code after all
I have a script that download's files from a server, all works nice. But
The problem: I have a legacy php app that is coded in no particular
first post so be nice :) My problem is that I have a class
I have coded a nice script but i am constantly getting Error on line
I have successfully coded URL redirection/rewriting, however, the whole thing seems to be kind
I have coded a pretty nice class and I'd like to install it on
I've coded a little game, but now I realized that I should include all

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.