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

  • Home
  • SEARCH
  • 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 6809199
In Process

The Archive Base Latest Questions

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

I have a view that includes a table. var newsIndexView = Backbone.View.extend({ … });

  • 0

I have a view that includes a table.

var newsIndexView = Backbone.View.extend({
   ...
});

Each Row in the table is another view associated with a model.

var newsItemView = Backbone.View.extend({
  tagName: "tr",
  ...
  selectRow: function(e){
    this.selected = !this.selected;
    $(this.el).toggleClass("selected");
    if(this.selected){
      $(".delete_many").on("click", $.proxy(this.remove, this));
    }else{
      $(".delete_many").off("click", $.proxy(this.remove, this));
    }
  },

  ...

});

The user can select rows. When 1 or more rows are selected a delete button appears. When the button (.delete_many) is selected I want to trigger the delete event for each selected newsItemView. As you can see when a row is selected I’m adding an event handler for it, and removing it when it is unselected. I was wondering if there is a better way of doing this?

  • 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-26T20:03:27+00:00Added an answer on May 26, 2026 at 8:03 pm

    Couldn’t you use delegateEvents on the view that manages the table to install the click handler once? It should fire, even if the buttons were added later (and stay around even if the buttons are removed later).

    var newsIndexView = Backbone.View.extend({
     events: {
      "click .deleteMany"  : "deleteMany"
     },
     ...
    

    The deleteMany function would then figure out which rows are selected and remove them in a loop. Since the button belongs to the table as a whole (and not to individual rows) this seems to be more natural. It would also make it easy to have a “are you sure” confirmation dialog (that you want to pop up just once and not for every row), and using bulk delete features of your server backend (one request instead of one for each row).

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

Sidebar

Related Questions

I have a detail view that includes three UIButtons, each of which pushes a
I have an initial table view that I created as the initial menu within
I have a view model that needs to encapsulate a couple of many-to-many relationships.
I have a foreach based table in my MVC partial view: <% foreach (var
I have a schema that includes tables like the following (pseudo schema): TABLE ItemCollection
I have a view that has a list of jobs in it, with data
I have a view that I want to add some custom drawing to. I
I have a View that can vary significantly, depending on the 'mode' a particular
I have a view that is joining two tables and ordering by the first
I have a view that is loaded in the MainWindow.xib. It is just a

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.