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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:44:47+00:00 2026-06-15T22:44:47+00:00

How can i add click event to my el elements in this case multiple

  • 0

How can i add click event to my el elements in this case multiple li’s. I’m trying to remove li from the dom on click, but the click event is not firing.

App.Views.ListItem = Backbone.View.extend({

    el : 'li',
    Wrapper : '#list_cntr ul',
    template : 'tmplItem',

    events : {
        'click li' : 'removeMe'
    },

    initialize : function() {

        this.render();
    },

    render : function() {
        $(this.Wrapper).prepend($(this.el).html(App.Templates[this.template](this.model.toJSON())));
    },

    removeMe : function() {
        var eventList = App.Collections.eventCollectionList;
        var eid = this.model.get('id');
        eventList.remove(eid);

       //How to remove the li?
    }

});
  • 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-15T22:44:48+00:00Added an answer on June 15, 2026 at 10:44 pm

    From the fine manual:

    delegateEvents delegateEvents([events])

    […] Omitting the selector causes the event to be bound to the view’s root element (this.el).

    The el for your view is the <li> that you want a click handler on so you should be able to drop the selector in your events:

    events : {
        'click' : 'removeMe'
    },
    

    That will bind removeMe to clicks on the <li> itself.

    You’re also setting el: 'li' when you want to say tagName: 'li'. The el property is your view’s DOM element but 'li' won’t do anything useful. If you specify a tagName then Backbone will create the <li> for you and this.el will be the view’s single <li>. This is probably where the strange “it looks like all the <li>s” behavior you’re seeing comes from.

    Your view should look more like this:

    App.Views.ListItem = Backbone.View.extend({
        tagName : 'li',
        //...
        events : {
            'click' : 'removeMe'
        },
        //...
        removeMe : function() {
            var eventList = App.Collections.eventCollectionList;
            var eid = this.model.get('id');
            eventList.remove(eid);
            this.remove();
        }
    });
    

    Demo: http://jsfiddle.net/ambiguous/MTh57/

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

Sidebar

Related Questions

This is the workflow: Add elements dynamically to a div container Register click event
How can I add click event to newly added item of menu? Below is
How can you add a click event to dynamically created menu item? I thought
Using Titanium Appcelerator I am trying to dynamically create elements and add event listeners
how can i add a custom view to the right click menu of every
When I go to Printers and Faxes dialog, I can click the Add a
I can add and remove the last line in my dynamic form and calculate
I can add a normal rightBarButton to my navigation without a problem but now
I can add a Conditional statement to a breakpoint, for instance arg0.startsWith(something) but i'd
I am working a project currently in which the user can add multiple news

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.