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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:43:40+00:00 2026-06-09T22:43:40+00:00

I tried to start to work with backbone.js, but I found the Event does

  • 0

I tried to start to work with backbone.js, but I found the Event does not work when I do NOT use ‘body’ as the View’s el.
Here is the code. You can save it as a html file and run it.

<html>
    <body>
        <button id='openEssay'>test</button>
        <div id='div' style='width:100px;height:100px;'></div><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
        <script src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.6/underscore-min.js"></script>
        <script src="http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js"></script><script>
    (function($){
        var AppView = Backbone.View.extend({

            el:'body',//success
    //fail  el:'#div',
    //fail    tagName: 'li',
    //fail    id:'div',
            initialize:function(){
                _.bindAll(this, 'openEssay');
            },
            events:{
                'click button#openEssay':'openEssay'
            },
            openEssay:function(){
                alert('a');
            }
       });
       var app = new AppView();
    })(jQuery);

    </script>
    </body>
    </html>
  • 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-09T22:43:41+00:00Added an answer on June 9, 2026 at 10:43 pm

    Backbone binds the event handlers to the view’s this.el using the delegation form of on (or delegate in older Backbones), see Backbone.View#delegateEvents for details. So if you want these events:

    events: {
        'click button#openEssay':'openEssay'
    }
    

    to do anything then this.$el.find('button#openEssay') needs to match something (where this is, of course, the view object). Only one of your four attempts:

    1. el: 'body'
    2. el:'#div'
    3. tagName: 'li'
    4. id: 'div'

    will put <button id="openEssay"> inside this.el so only (1) will call openEssay when you hit the button. If you put your button inside #div then (2) would also work.

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

Sidebar

Related Questions

I've tried '--kiosk', '--start-maximized'; but all not work, any solution yet? Further, the web
I have no idea where to start. i tried DataTable but it didn't work.(This
So I've tried to work with the pure-CSS, never-use-tables-for-layout gospel, I really have. But
I'm trying to work on a bmp file. For a start i tried to
When it comes to web development I have always tried to work SMART not
I've tried getting the launch link from the start menu and using Process.Start() But
I don't know if it's a bug or not, but here's my problem: I
I start using mechanize with Rails, but seems it doesn't work correctly, it won't
I've tried the typical physics equations for this but none of them really work
I tried to start my avd on Ubuntu 64bit 10.10, but it failed and

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.