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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:35:45+00:00 2026-05-26T14:35:45+00:00

I have a view that creates and populates a Selectlist. I want to bind

  • 0

I have a view that creates and populates a Selectlist. I want to bind an event on the Change event (When the user selects a different Option.

It simply outputs something close to this:

<select>
   <option value="id">ID Name</option
</select>

The View:

App.Views.SessionList = Backbone.View.extend({
   tagName: 'select',
   id: 'sessionList',
   events: {
       'change': 'selectionChanged'
   },
   initialize: function () {
       // Load Collection
       _.bindAll(this, 'selectionChanged');

       this.template = _.template($('#optionsTemplate').html());
       this.Sessiontemplate = _.template($('#session_template').html());
       this.SelectedSessiontemplate = _.template($('#selected_session_template').html());

       // Create Collection
       this.SessionList = new App.Collections.SessionList();

       // Set Bindings
       this.SessionList.bind('add', this.addSession, this);
       this.SessionList.bind('reset', this.addSessions, this);


       this.render();

       this.SessionList.fetch();
   },
   render: function () {

       return this;
   },
   addSession: function (item, num) {
       if (num === 0) {
           $(this.el).append(this.SelectedSessiontemplate(item.toJSON()));
           console.log("Selected");
       }
       else {
           $(this.el).append(this.Sessiontemplate(item.toJSON()));
       }
   },
   addSessions: function () {
       var self = this;
       // Add all Rows
       for (var i = 0; i < self.SessionList.models.length; i++) {
           this.addSession(self.SessionList.models[i], i);
       }
   },
   selectionChanged: function (e) {
       var field = $(e.currentTarget);
       var value = $("option:selected", field).val();
   }
});

The Session Template is just simply:

<option value="{{Id}}">{{Name}}</option>

The event never gets triggered, and It seems that it isn’t getting binded correctly. I want to trigger it on the change of the select list.

I originally thought I may be having an issue similar to:
backbone.js events and el, however it doesn’t work in this case.

  • 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-26T14:35:46+00:00Added an answer on May 26, 2026 at 2:35 pm

    It is hard to debug your problem directly, because we don’t have all of the information (what does SessionList look like… the templates, etc).

    BUT, I have paired down your example to some code where the event does, indeed work. Hopefully, you can build it up from there? You can fork the jsFiddle if you want to get to a place where it fails for you and we can try to help further.

    window.App = { Views: {} };
    
    App.Views.SessionList = Backbone.View.extend({
        tagName: 'select',
    
        events: {
            'change': 'selectionChanged'
        },
    
        initialize: function () {
            _.bindAll(this, 'selectionChanged');
            this.render();
        },
    
        render: function () {
            $(this.el).append('<option value="foo">Option 1</option>');
            $(this.el).append('<option value="bar">Option 2</option>');                
            return this;
        },
    
        selectionChanged: function (e) {
            var value = $(e.currentTarget).val();
            console.log("SELECTED", value);
        }
    });
    
    var view = new App.Views.SessionList();
    $("body").append(view.el);
    

    Given that code, you will get a console log with the value every time you select an item.

    Since you aren’t getting that, I am guessing you are seeing an exception or something like that? Does your debugger give you any hints?

    Good luck!

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

Sidebar

Related Questions

In a word, how? I have a view controller that creates a few custom
I have a for loop that creates multiple UIImageViews that I add to self.view
I have a view that I want to add some custom drawing to. I
I have an app that populates list views when a view is created. I
I have a form view model class that populates Select Lists for use by
I have created a list view that displays the names and dates of items
We have created a new List View Style that shows thumbnails from a picture
If i have a controller action Create that returns a view with the following
if i have created a view model and have a partial form that is
I have a view that has a list of jobs in it, with data

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.