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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:06:04+00:00 2026-05-20T14:06:04+00:00

I’ve created a 2d slider in jQuery in which 2 parameters are manipulated simultaneously

  • 0

I’ve created a “2d slider” in jQuery in which 2 parameters are manipulated simultaneously by dragging a “handle” within a bounding box.

I’ve implemented this by nesting a “handle” div within a parent div, and using the jQuery UI plugin to facilitate the dragging behaviour. The html looks like:

<div class="Slider2d" id="grid_spacing_both">
    <div class="Slider2dHandle" id="grid_spacing_both_handle"></div>
</div>

The jQuery looks like:

$(".Slider2dHandle").draggable({
    containment: "parent",
    scroll: false,
    drag: function(event, ui) {
        // calculates position and updates value input boxes
    }
});

I’ve also created some code that repositions the handle to the location of any clicks within the parent div:

$(".Slider2d").mousedown(function(event){
    // get location of click and reposition handle to click location
});

What I would like to do is modify the above method so that the user can click somewhere in the parent div, have the handle repositioned to the click location, and then begin dragging the handle without letting the mouse button up. Basically, I need to figure out a way to programmatically trigger the drag functionality.

I found a few suggestions here and here, and attempted to implement their recommendations by changing the above method like so:

$(".Slider2d").mousedown(function(event){
    // get location of click and reposition handle to click location
    handle = $(".Slider2d").children(".Slider2dHandle");
    handle.trigger(event);
});

This works in the most technical sense, but its super slow and I get a bunch of error messages from Safari telling me “RangeError: Maximum call stack size exceeded.” What I’m thinking is happening is that the when I trigger the event on the handle, it bubbles up to the parent, which then calls the trigger again and so on and so on. I’ve tried to stop the bubbling by throwing an event.stopPropagation into my code before and after the .trigger() call, but to no avail.

So, if anyone has any suggestions on how to get this working I’d really appreciate it. I have a backup plan here, but this seems to me to be unnecessarily complicated.

Thanks!

  • 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-20T14:06:05+00:00Added an answer on May 20, 2026 at 2:06 pm

    I managed to get this working. As I suspected, it had something to do with event handling.

    The fix was simple: I modified the above code to check if the event target was the same as the element to which the callback was bound (ie, slider bounding box). On the initial click that repositions the handle, these are the same elements. However, when the handle’s mousedown event is triggered, and the event bubbles up to the bounding box, the target of that event is the slider handle. So, they don’t match, and the trigger event isn’t called again, setting off an infinite loop.

    At least I think that’s what’s going on. In any case, here’s the code that worked:

    $(".Slider2d").mousedown(function(event){
        // get location of click and reposition handle to click location 
    
        handle = $(".Slider2d").children(".Slider2dHandle");
        if ($(this).attr("id") == $(event.target).attr("id")) {
            handle.trigger(event);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
i want to parse a xhtml file and display in UITableView. what is the
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.