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

  • Home
  • SEARCH
  • 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 6979367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:52:40+00:00 2026-05-27T17:52:40+00:00

Say I have a website with some fields that I want to run some

  • 0

Say I have a website with some fields that I want to run some calculations on. I have a quantity input, and in my backbone.js View I bound the “change” event to this input.

How do I get the value of the changes to the input field?

I found this method (below) to get the value, but it feels wrong since I have to know the element ID again in my function. I couldn’t do this with a class, for example.

window.Calculations = Backbone.View.extend({

    (...)

    events: {
        'change input#quantity': 'changeQuantity'
    },


    changeQuantity: function() {
        var val = $(this.el).find('input#quantity').val();
        this.model.set({'quantity': val});
    }

});

And in the HTML:

<input type="text" id="quantity" value="<%= quantity %>">

Am I approaching this correctly? Is there a variable that access the object that was changed? I know that $(this.el) isn’t it, it’s just the container.

  • 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-27T17:52:41+00:00Added an answer on May 27, 2026 at 5:52 pm

    jQuery sends an event object to your function changeQuantity. With it, you can retrieve the changed input.

    window.Calculations = Backbone.View.extend({
    
        //(...)
    
        events: {
            'change input#quantity': 'changeQuantity'
        },
    
    
        changeQuantity: function(e) {
            var val = $(e.currentTarget).val();
            this.model.set({'quantity': val});
        }
    
    });
    

    I created a jsfiddle as an example : http://jsfiddle.net/tz3XS/138/

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

Sidebar

Related Questions

Lets say i have a website mysite.com that will store some sensitive personal data
Let say that I have a website with some information that could be access
Let's say I have a flash video streaming website, what are some ways in
Say I have a website and a database of that website hosted locally on
I have a website I want to regexp on, say http://www.ru.wikipedia.org/wiki/perl . The site
I have 1 blog say xyz.blogspot.com ,now am uploading my own website,so I want
I have a website that stores quotes and users can add some quotes to
Say we have a website that responds to a host header kebab-shop.intra.net Is is
I have this website that stores latitude and longitude of some places and I
Say you have a legacy website running on an old code-base that offers certain

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.