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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:13:24+00:00 2026-05-31T22:13:24+00:00

I have followed numerous screen casts as well as trawled the backbone docs extensively

  • 0

I have followed numerous screen casts as well as trawled the backbone docs extensively and I cannot figure out why my view events are not being fired. My (short) code for testing is as follows:

<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/underscore.min.js"></script>
<script type="text/javascript" src="js/backbone.min.js"></script>

<script type="text/javascript">
    
    var App = (function($){
        
        var NavigationItemView = Backbone.View.extend({
            el: '#navigation',
            initialize: function(params){
                this.label = params.label;
                this.appendTo = params.appendTo;
            },
            events: {
                "click #add" : "test"
            },
            test: function(){
                $(this.el).html("<li>Testing...</li>");
            },
            render: function(){
                $(this.el).html("<li><a href=\"#\">"+this.label+"</a></li>");
            }
        })
        
        var self = {};
        self.init = function(){
            new NavigationItemView({ label: 'Test Nav Label' });
        }
        
        return self;
    });
    
    $(document).ready(function(){
         App(jQuery).init();
    })
    
</script>

If I change the init method code from this:

new NavigationItemView({ label: 'Test Nav Label' })

To this:

new NavigationItemView({ label: 'Test Nav Label' }).render()

The render method is called perfectly, indicating there is no issues with the set up of the view. I can replace render() with test() and likewise it works.

However, the event of clicking on the link with ID #add does not fire the test even, and surely it should? To clarify, I do have a link with id ‘add’ in the DOM, I have checked and checked again.

If I add event hooks using jQuery and fire off certain methods of the view manually, that works. It’s backbones own event hooks that are not working for me.

I have looked at the related posts, and most of the suggestions were use the el property, which I have. #navigation is an empty <ul> in my case. I have changed it to a div but with no change in behaviour.

All help much 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-31T22:13:26+00:00Added an answer on May 31, 2026 at 10:13 pm

    Is your #add element a child of your view element (#navigation)?
    Events are fired only on children elements of you view “el”. For instance, this will not work:

    <div id="navigation">
        ...
    </div>
    
    <div id="add">
        ...
    </div>
    

    While this will:

    <div id="navigation">
        ...
        <div id="add">
            ...
        </div>
        ...
     </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have followed the Poll tutorial on http://docs.djangoproject.com . I would like to know
I have followed the directions laid out in the book entitled Version Control With
I have followed this tutorial http://blogs.wrox.com/article/creating-a-simple-ipad-application-table-view/ (creating a uitableview and populating it). I want
I have followed a screen cast form ryan bates railscast and every thing is
I have followed numerous posts for the last two days. Firefox won't play the
I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get
I have followed the blog post written by Steve Sanderson at blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc . It
I have followed the suggestion in this question... [ How to handle checkboxes in
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
I have followed the suggestion in this question as I am using Django, I

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.