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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:48:26+00:00 2026-05-27T03:48:26+00:00

I’m running into a blind spot with backbone.js. I’ve written this code and all

  • 0

I’m running into a blind spot with backbone.js. I’ve written this code and all I’m trying to do is get
the test div to render on button click. If I call render() within the initialize() function, it does render.
However, I never trigger the render() function in response to the click event.

What am I missing?

Thanks!

HTML Container

<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8' />
    <!-- / Always force latest IE rendering engine (even in intranet) & Chrome Frame -->
    <meta content='IE=edge,chrome=1' />
    <meta http-equiv='X-UA-Compatible' />
    <link type="text/css" rel="stylesheet" href="/stylesheets/site.css" media="screen" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
    <script type="text/javascript" src="/javascripts/underscore-min.js"></script>
    <script type="text/javascript" src="/javascripts/backbone-min.js"></script>
    <script type="text/javascript" src="/javascripts/application.js"></script>
    <script type="text/javascript" src="/javascripts/sample_data.js"></script>
    <title>The Middleman!</title>
  </head>
  <body class='page_classes'>
    <div id='main' role='main'>
      <h1>The Middleman is watching.</h1>
      <div id='band-app'>
        <button id='new-band'>new band</button>
      </div>
    </div>
  </body>
</html>

Coffeescript for simple view

SAMPLE_TEMPLATE = """
<div id="my-fine-id">
  My fine id!!!
</div>
"""

$ ->
  class AppView extends Backbone.View
    render: ->
      console.log "rendering"
      @template = _.template SAMPLE_TEMPLATE, {}
      @el.html @template

    initialize: ->
      console.log "constructing"
      @el = $('#band-app')
      @events = {"click button#new-band": "render"}

  app = new AppView()
  • 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-27T03:48:26+00:00Added an answer on May 27, 2026 at 3:48 am

    I think delegateEvents, which sets up the event handling, gets called in the View constructor, before initialize gets called, so either call it explicitely in your initialize method (after you have set up the events map), or make sure that the events map is set up as part of constructing the View class itself, see:

    http://documentcloud.github.com/backbone/#View-extend

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
For some reason, after submitting a string like this Jack’s Spindle from a text

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.