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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:31:07+00:00 2026-06-12T17:31:07+00:00

I am using jquery-select2 library to implement my dropdowns. In my case, I would

  • 0

I am using jquery-select2 library to implement my dropdowns.

In my case, I would like to be able to trigger an action after a user clicks on the option in the dropdown list. However, the click or change event doesn’t seem to work

haml file:

%select.medium.name_selector.pull_left
  %option.placeholder{value:"placeholder", disabled: "disabled", selected: "selected"} Start or find a conversation with a muser
  %option{value: "nick"} nick
  %option{value: "sam"} sam
  %option{value: "john} john

coffeescript file:

events:
  "click option" : "displayChatScreen"

displayChatScreen: (e) ->
  e.preventDefault()
  nickname = @$("select.name_selector option:selected").val()
  if nickname != "placeholder"
    Backbone.history.navigate "messages/#{nickname}",
      trigger: true
  else
    alert "You need to select a friend to chat"

Is there anyway to trigger the action once I change the option of my select2 dropdown box?

Note: I have tried both click and change events and they both do not work

  • 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-06-12T17:31:09+00:00Added an answer on June 12, 2026 at 5:31 pm

    With select2 you can’t use the normal change event as you would for a normal <select> widget, but you actually need to attach your displayChatScreen method to the change handler provided by select2.

    e.g.

    $('select.medium.name_selector').on('change', this.displayChatScreen);
    

    Assuming that’s the selector for your select2 widget and you’re running that in the appropriate context.

    When you use the default events hash provided by Backbone, you’re really doing this:

    $el.on('change', 'option', this.displayChatScreen);
    

    Since select2 actually replaces the <select> (and therefore <option> tags with a <ul> <li> pair) you’ll never actually receive the browser event.

    Additionally, the change event fires on the parent <select> not the <option> element.

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

Sidebar

Related Questions

I would like to print the selected values of all selects using jQuery. I
Using jQuery Nearest Element , I would like to select elements in a circular
Using jQuery's dialog I came across the following quirk (tested in FF3): User selects
Using JQuery, is there a simple way to select the text immediately after a
I'm using jQuery UI sortable plugin to be able to select and sort items.
Im using a simple select list and the jquery.dropkick library to make it beautiful.
I'm using jquery mobile 1.0 in combination with swipejs. The swipejs library is being
I'm trying to do my own drag and drop function using jquery library. But
I'm using that jQuery Vertical Menu Library www.dynamicdrive.com/dynamicindex1/ddsmoothmenu.htm I want to accomplish the selection
I'm using jQuery 1.7.1, and no other JS library/framework. I can select most elements

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.