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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:26:50+00:00 2026-05-27T04:26:50+00:00

I want a button which opens the fancybox rel-group with a certain picture. I’m

  • 0

I want a button which opens the fancybox rel-group with a certain picture. I’m not quite sure if this works but I’ll give it a try. My problem is that I want to execute jQuery if the user clicks on a link. This is the code I have

var js = "jQuery.fancybox.pos("+currentImage+");";
// create a new function from the "js" string
var newclick = new Function(js);

jQuery("a.enlarge").click(newclick);

The code is based on this answer. I hope that
jQuery.fancybox.pos(2) works. But currently I’m not getting the click function to work. What I’m doing wrong?

Edit:

My current setup:

<script type="text/javascript">
  var currentImage = 0;

  function getCurrImage(carousel, state){
     currentImage = carousel.first-1;

     jQuery("a.enlarge").click(function() {
       alert(currentImage);   
       jQuery.fancybox.pos(currentImage);
     });
   }

   jQuery.noConflict();

   jQuery(document).ready(function() {
       jQuery('#mycarousel').jcarousel({
           scroll:1,
           'itemLoadCallback': getCurrImage 
       }); 
       jQuery('a[rel=example_group]').fancybox({
           'transitionIn': 'none',
           'transitionOut': 'none'
       });
   });
</script>

jQuery.fancybox.pos(currentImage); doesn’t work. currentImage seems to be correct, but the alert pops up 4 times if the button was clicked 4 times. That means:

click 1: currentImage=0
click 2: currentImage=1, currentImage=1
click 3: currentImage=2, currentImage=2, currentImage=2
click 4: currentImage=3, currentImage=3, currentImage=3, currentImage=3

Update:

New try:

<script type="text/javascript">
  var currentImage = 0;

function openfancy(){
   jQuery.fancybox.pos(currentImage);
}

  function getCurrImage(carousel, state){
     currentImage = carousel.first-1;

     jQuery("a.enlarge").unbind("click", openfancy);
     jQuery("a.enlarge").bind("click", openfancy);
   }

   jQuery.noConflict();

   jQuery(document).ready(function() {
       jQuery('#mycarousel').jcarousel({
           scroll:1,
           'itemLoadCallback': getCurrImage 
       }); 
       jQuery('a[rel=example_group]').fancybox({
           'transitionIn': 'none',
           'transitionOut': 'none'
       });
   });
</script>

jQuery.fancybox.pos(currentImage); still doesn’t work. Is there any chance? Perhaps its because I have multiple fancyboxes on that page? I also tried it with jQuery('.fancybox').fancybox.pos(currentImage); but I get the error message that it is not a function.

  • 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-27T04:26:51+00:00Added an answer on May 27, 2026 at 4:26 am

    The pos function never worked. So I took the idea of a deleted answer to use the click-function. If a user clicks on my link it should simulate the click on the picture in the gallery.

    <script type="text/javascript">
        var currentImage = 0;
    
        function getCurrImage(carousel, state){
            currentImage = carousel.first-1;
        }
    
        /*jQuery.noConflict();*/
    
        jQuery(document).ready(function() {
            jQuery('#fancycarousel').jcarousel({
                scroll:1,
                'itemLoadCallback': getCurrImage 
            }); 
            jQuery('a[rel=example_group]').fancybox({
                'transitionIn': 'none',
                'transitionOut': 'none'
            });
            jQuery('#enlarge').click(function(){
                jQuery(".jcarousel-item").eq(currentImage).children("a").click();
            }); 
        });
    </script>
    

    I needed hours to figure this out!

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

Sidebar

Related Questions

i want to create a button which works like a real back button.When i
I want to make somethink like hyperlink. Right now, i created button, which opens
I have an ASP.NET button in my application, which I want to open another
In my app I want a button which when pressed copies a file stored
I have created a button which I want to expand/contract. I found a way
I have a form which I want to submit upon button click which is
I want to add a column to a gridview which contains button control. I
want to have a Hyperlink-Button in a gridView in which I can display a
I want a ComboBox which has no drop-down button but can still be opened
I want to create a dialog which appears when user presses a button. (In

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.