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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:22:15+00:00 2026-06-03T16:22:15+00:00

I have an application with a nested list I am trying to manage with

  • 0

I have an application with a nested list I am trying to manage with backbone. there is a view for each individual <li> element, but each list element has it’s own nested <ul> tag, which has its own view instantiated. here is an example:

HTML

<ul class='elements'>
  <li class='element'>
     <div>
       <a class='edit-element'>Edit</a>
     </div>
     <ul class='elements'>
       <li class='element'>
         <div>
           <a class='edit-element'>Edit</a>
         </div>
       </li>
     </ul>
   </li>
</ul>

JavaScript

element_view = Backbone.view.extend({
  events: {
    'click .edit-element' : 'edit_element'
  },
  edit_element : function(event) {
    //code to handle editing of an element
  } 
});

The issue is that if I click on a child element, both views will fire there edit_element event, which is problematic for several reasons. How can I structure this so that when I click a link in a child <li>, it fires for that <li>, and not any <li>s that contain it?

  • 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-03T16:22:17+00:00Added an answer on June 3, 2026 at 4:22 pm

    Backbone’s event handlers are just plain old jQuery event handlers so you can stop propagation in the usual ways using stopPropagation:

    edit_element: function(event) {
        event.stopPropagation()
        //...
    }
    

    Demo: http://jsfiddle.net/ambiguous/Yb8rg/1/

    Or by returning false:

    edit_element: function(event) {
        //...
        return false;
    }
    

    Demo: http://jsfiddle.net/ambiguous/QvaGM/1/

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

Sidebar

Related Questions

In my Ruby on Rails application, each group has_many :expenses. I have nested my
I have a nested list in my application : this.nestedList = new Ext.NestedList({ store:
I have an application which contains a nested list box, that is a list
I have some nested models in my Rails application. i have an article hat
I have Application X with Subform x1, x2, x3. The Subform has, because its
I have a PocketPC C# application written in Visual Studio 2005. It uses nested
I have an application with width/height of 100%. I have several nested groups within
I have list of divs with some data in there: <div style=border: 1px solid
I have this nested list structure. My tree can go to n level. I
I have a dictionary with nested dictionaries (as per flash cards) in my application.

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.