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

The Archive Base Latest Questions

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

Going through a very basic tutorial on backbone.js views. The expected behavior is to

  • 0

Going through a very basic tutorial on backbone.js views.

The expected behavior is to call the render function when #sayhello button is clicked. Render simply uses jQuery’s html method to put “hello Bud Abbot” in el.

But when I click the #sayhello button, nothing happens. No errors or anything. I set a breakpoint in firebug and watch it just skip the render function.

Here’s the js:

App = (function($){
jQueryView = Backbone.View.extend({
    initialize: function(){
        this.el = $(this.el);
    }
});

HelloWorldView = jQueryView.extend({
    el: $('#helloworld'),
    events:{ 'click #sayhello': 'render'
    },
    initialize: function(params){
        jQueryView.prototype.initialize.call(this);
        this.name = params.name;
    },

    render: function(){
        console.log("rendering");
        this.el.html("hello " + this.name);
    }
});

var self = {};
self.start = function(){
    new HelloWorldView({name: 'Bud Abbot'});
};
return self;

});

And here’s the html:

    <div id="helloworld"></div>
<button id="sayhello">Say Hello</button>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.4/underscore-min.js"></script>
<script src="http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js"></script>

What seems strange is when I change this:

new HelloWorldView({name: 'Bud Abbot'});

to this:

new HelloWorldView({name: 'Bud Abbot'}).render();

the render method is called, but when I try to do it with an event – no dice. Any help to understand what I’m doing wrong is greatly appreciated.

  • 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-26T01:48:42+00:00Added an answer on May 26, 2026 at 1:48 am

    It’s because #sayhello is not part of your view. Try putting #sayhello inside #helloworld:

    <div id="helloworld">
        <button id="sayhello">Say Hello</button>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going through a very basic php tutorial and am creating a calculator so
I was going through this tutorial for fun, and got stuck on the very
Going through the microsoft authentication tutorial listed here they have you create a master
Going through some of my older Delphi projects and upgrading them to D2009, as
Going through Javascript documentation, I found the following two functions on a Javascript object
While going through university and from following the development of SO, I've heard a
After going through the Appendix A, C# Coding Style Conventions of the great book
While going through many resources on multithreaded programming, reference to volatile specifier usually comes
Just going through the sample Scala code on Scala website, but encountered an annoying
I'm going through the problems on projecteuler.net to learn how to program in Erlang,

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.