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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:14:25+00:00 2026-05-23T22:14:25+00:00

I built a cascading dropdown in jquery, modified from a few examples. I added

  • 0

I built a cascading dropdown in jquery, modified from a few examples. I added a feature to let the user “back up” and reselect an earlier dropdown. This reloads the next dropdown, and clears and disables the subsequent ones.

http://jsfiddle.net/goodeye/gA6GZ/

The problem is after the first time through, the select elements’ change events are bound, so I think reloading new values is causing the later change events to fire.

I separated out the .change() bind, instead of chaining it. I previously had it chained before loading the select options. This helped the first time through, but not subsequent times.

For this problem, I’m specifically looking for a good approach to this sequence:

  • avoid change()
  • update the dropdowns
  • set up change()

This question:
Best way to remove an event handler in jQuery?
has unbind() as the main answer, then a subsequent answer to use live(). The live() approach uses a class which is slightly confusing me, and didn’t get as many votes.

To reproduce:
Select step 1, see step 2 fire.
Select step 2, see step 3 fire.
Select step 1 again, see step 2 fire.
then the trouble starts:
Select step 2, see step 3 fire twice.
Select step 3, see step 4 fire three times.
Select step 1 again, see step 2 fire twice.
etc.
It even gets worse; I’ll see step 3 fire five times.

Some details:

In the real code, these load from a json ajax call. I removed that from the example, and added hard-coded options to simulate it, scoping this to just the event issue.

This starts out server-side, so the first dropdown is already “in” the html. The next three are loaded from (simulated) json calls.

These use classes for identification, because the real page has more than one set of these dropdowns. The code uses $(this) to be careful to work within the one set that was selected.

There is also a feature to ‘auto select’ if there’s only one option, and move on to the next one. This code is in there, but the simulated examples all have more than one option, to avoid this issue for this question.

Thanks in advance for your ideas!

  • 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-23T22:14:26+00:00Added an answer on May 23, 2026 at 10:14 pm

    Well, I ran out of time and had to solve it. It was simply to set up the binding once – that’s all there was to it. So this solves the problem, and didn’t need to unbind/rebind, or use live() in this case.

    Do the following code once up front. It binds the dropdowns once, and disables the 2nd, 3rd, 4th until the cascading starts from calling the first one. So the binding is done once, then disabled true/false is toggled.

    $('.ddStep1').change(getStep2);
    $('.ddStep2').change(getStep3).attr('disabled', true);
    $('.ddStep3').change(getStep4).attr('disabled', true);
    $('.ddStep4').attr('disabled', true);
    

    (In this application, the last dropdown doesn’t have a change event; there’s a separate submit button after the 4th is selected.)

    The problem was the multiple calls to create the binding – this is a one-time thing, so calling it more than once was attaching multiple calls on the change event.

    Adding and removing the select options wasn’t calling the change event.

    Answering the original question about temporarily disabling the event (albeit not the solution for my problem), I did get to understand using live() from this answer, and think that would be the way to go:
    Best way to remove an event handler in jQuery?
    The other answer to that question using namespaces looks decent too.

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

Sidebar

Related Questions

I built an application which displays the records from database in the window and
I have a custom built ajax [div] based dynamic dropdown. I have an [input]
I built an iPhone app that is getting information from a server (this is
I built a form in sales force and added it to my site. The
Any built in way to get virtual / relative path or URL from absolute
The built-in photo gallery hides the soft keys (back, home, etc.), clock, and notification
I built my own Jquery tooltip function, it worked for 3 months really good,
Which built in (if any) tool can I use to determine the allocation unit
We built a grant application system for a client. They've now asked for some
The built-in Math.Pow() function in .NET raises a double base to a double exponent

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.