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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:44:51+00:00 2026-06-17T11:44:51+00:00

I have a template in underscore having a button inside it. I want a

  • 0

I have a template in underscore having a button inside it. I want a click event to be mentioned in the event hash in the backbone view.

template code is:

<script type="text/template" id="ledgerListing">

<button class="btn btn-danger pull-right" id="addLedgerButton">Add Ledger</button>

</script>

View Code is:

app.ledgerView=Backbone.View.extend({

el:"#container",

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

events: {},


   initialize: function(){

    },

    render: function()
{
    this.$el.html(template())

}

}); 

Now how to specify the click event in the event hash for the button with id addLedgerButton

  • 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-17T11:44:53+00:00Added an answer on June 17, 2026 at 11:44 am

    Your can add events as the following, (format should be event type and a space and the element

    events: {
      'click #addLedgerButton': 'myclick'
    },
    

    and define a function named myclick:

    myclick: function () {
      alert(1);
    }
    

    Here is jsfiddle. http://jsfiddle.net/w2jm7/

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

Sidebar

Related Questions

I have a backbone.js/underscore.js template that I am feeding into a backbone view for
I've a backbone view that renders a search result in a underscore template. As
I am using underscore.js's templating capabilities from backbone.js, I have the following template that
I have the following backbone.js client side template: <script id=calleeTemplate type=text/x-jquery-tmpl> <tr style=background-color: ${StatusColour}>
I'm using underscore template engine for an backbone application. As of now I have
I'm using the underscore.js templating function and have done a template like this: <script
I have template codes with nested curly braces like this: {code{attributes}} I want both
I'm having trouble with passing model data from a Backbone View to a template
I am using underscore template engine (as part of Backbone.js) and have an issue
I have JavaScript application, where I use client-side templates (underscore.js, Backbone.js). Data for initial

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.