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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:19:20+00:00 2026-05-30T17:19:20+00:00

I am getting started with backbone.js but it seems i am not able to

  • 0

I am getting started with backbone.js but it seems i am not able to get the first hand code correct. I looked up all the resources but cant figure out what is the problem.

I was expecting changed event getting fired every time i change something in the input box and finally when i click the button, it should fire someAction function. There are no JavaScript errors but nothing happens. no change or click event getting fired.

Can someone please tell me what am i missing here?

Aspx Page:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" 
Inherits="_Default" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script src="jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>
    <script src="underscore.js" type="text/javascript"></script>
    <script src="Backbone.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function() {

            Person = Backbone.Model.extend({
            el: '#form1',

            events : {
                "click #DoSomething": "someAction"
                },

            initialize: function(){
                //This will bind change event of input controls to below function
                _.bindAll(this, "changed");
                },

                //This function will be fired whenever value in the input is changed
                changed: function(evt) {
                    var target = $(evt.currentTarget),
                    data = {};
                    data[target.attr('name')] = target.attr('value');
                    this.model.set(data);
                    alert('Model Updated')
                },

            //take some action on click of a button
            someAction: function(){
                var fName = this.model.get('FirstName');
                var lName = this.model.get('LastName');
                alert("First Name" + fName + " Last Name " + lName);
                return false;
          }
        });
    });

    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <span>First Name</span>
        <input type="text" name="FirstName" id="txtFirstName" value="Mark" />
        <span>Last Name</span><input type="text" name="LastName" id="txtLastName" value="Waugh" />
        <input type="button" id="DoSomething" value="Login Here" />
    </div>
    </form>
</body>
</html>
  • 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-30T17:19:21+00:00Added an answer on May 30, 2026 at 5:19 pm

    All of your functionality should be in a view not a model.

    Change Person = Backbone.Model.extend to PersonView = Backbone.View.extend. Now you actually have to create an instance of the view.

    $(function() {
      PersonView = Backbone.View.extend({
      ...
      });
      window.personview = new PersonView();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting started with backbone.js... but couldn't get it to work at all. <script
I am just getting started with Backbone.js , but it looks really interesting... Right
Getting started on writing my first build script. I dont get the whole dependency
Just getting started with MSpec and I can't seem to quite get my first
Just getting started with backbone, and I thought I was familiar with all the
I am just getting started with flex and am using the SDK (not Flex
I started integrating backbone in my project. The very first difficulty that i had
Getting started with Django 1.3 here. Loving the system so far, but struggling on
I'm just getting started on Sitecore DMS 2.0, and not sure if I understand
I'm currently getting started with Backbone.js. I've wrote some examples with Backbone and they

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.