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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:00:42+00:00 2026-06-17T12:00:42+00:00

I am starting with my first backbonejs app. I just have the two buttons

  • 0

I am starting with my first backbonejs app. I just have the two buttons for which i want to populate the template with a simple value. Here is the complete code for my page:

<script src="http://code.jquery.com/jquery-latest.js"></script>   


<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone-localstorage.js/1.0/backbone.localStorage-min.js" type="text/javascript"></script>  


</head>

 <body>
 <button class="btn" id="dashboardBtn">Dashboard</button><button id="ledgersBtn" class="btn btn-warning">Ledgers</button>

 <script type="text/template" id="heading">  
 <h1><%= heading %></h1>
 </script>

  <div id="container">Loading...</div>



  <!-- JAVASCRIPT -->
  <script type="text/javascript">
  var app ={};

  app.Page=Backbone.View.extend({

el:"#container",

template: _.template($("#heading").html()),

events:{
    'click #dashboardBtn':'loadDashboard',
    'click #ledgerBtn':'loadLedger'
},

loadDashboard: function(){

    this.$el.html(template({heading:"Dashboard"})); 
    },

loadLedger: function(){
    this.$el.html(template({heading:"Ledgers"}));
}

});


 //-----------INITIALIZERS----------------
 app.page=new app.Page();


  </script>

When i click on the buttons, nothing happens. Nothing is shown in the console as well. I know i am doing something stupid here but don’t know what. Help..

  • 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-17T12:00:43+00:00Added an answer on June 17, 2026 at 12:00 pm

    I think the problem is the events part:

    events:{
        'click dashboardBtn':'loadDashboard',
        'click ledgerBtn':'loadLedger'
    }
    

    dashboardBtn and ledgersBtn (be aware that you’ve typed it with ‘s’ in the button element and without it in the events object) are ids, so it should look like this:

    events:{
        'click #dashboardBtn':'loadDashboard',
        'click #ledgerBtn':'loadLedger'
    }
    

    EDIT:

    I just realized that you set the view’s el to #container, so the events object will reference everything it is inside of #container. So I would wrap the buttons:

    <div id="container2">
       <button class="btn" id="dashboardBtn">Dashboard</button><button id="ledgersBtn"class="btn btn-warning">Ledgers</button>
    </div>
    

    And the javascript code would be:

    app.Page=Backbone.View.extend({
    
    el:"#container2",
    
    template: _.template($("#heading").html()),
    
    events:{
        'click #dashboardBtn':'loadDashboard',
        'click #ledgersBtn':'loadLedger'
    },
    
    loadDashboard: function(){
    
        this.$el.html(this.template({heading:"Dashboard"})); 
        },
    
    loadLedger: function(){
        this.$el.html(this.template({heading:"Ledgers"}));
    }
    
    });
    

    Besides, notice that you were calling template directly in loadDashboard and loadLedger, instead of this.template

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

Sidebar

Related Questions

I'm currently just starting my first Lua program and I have a .csv file
I am just starting to learn Ruby (first time programming), and have a basic
I am just starting my first MVC Web Application and have noticed that I
Starting my first serious GUI app in C#. I have a class that is
I'm starting my first C# project, and I want to make a form designer
Now on my localhost I'm starting developing first simple web service using ruby 1.9.2
I am new to Blackberry programming and starting my first app soon. I believe
Starting at http://developer.android.com/training/index.html I selected the [ FIRST CLASS > ] button which takes
I'm starting on work on my first Windows Mobile 6.5 app in C#, and
I'm starting my first Drupal project, pretty excited :) I have a question; the

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.