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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:24:25+00:00 2026-06-08T15:24:25+00:00

I got following nested View structure: LayoutView – SidebarView – ContactListView – ContactItemView –

  • 0

I got following nested View structure:

LayoutView
  - SidebarView
    - ContactListView
      - ContactItemView
  - ContentView

Now imagine following situation:

A user clicks on a ContactItem. Now the ContactItem should call an event or something else which renders the profile of the clicked contact in the ContentView.

I have no idea how I could do this without breaking the flexibility…

  • 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-08T15:24:26+00:00Added an answer on June 8, 2026 at 3:24 pm

    You probably want to use Events to hook them together, rather than having the ContactItemView directly call the ContentView. As you’re creating the views, each parent view can bind to the child view’s events. Then when the click happens, it will bubble up through the chain until the appropriate view handles it.

    Here’s a simple example to show the general idea. I’m presenting this in the order that the event bubbling happens, which is hopefully a little bit clearer.

    First, the ContactItemView gets the DOM click event and triggers a Backbone event for it.

    //ContactItemView.js
    events : {
       "click .contactName" : "click"
    },
    
    click : function(evt){
       this.trigger("clicked", this);
    }
    

    The ContactListView can listen for that and republish it:

    //ContactListView.js    
    render : function(){
     var itemView = new ContactItemView();
     itemView.on("clicked", this.itemClicked, this);
    },
    
    itemClicked : function(item){
      this.trigger("clicked", item);
    }
    

    The SidebarView listens for that event, and actually knows what to do with it:

    //SidebarView.js    
    render: function(){
      var listView = new ContactListView();
      this.contentView = new ContentView();
      listView.on(clicked, this.contactItemClicked, this);
    },
    
    contactItemClicked : function(contactItem){
       this.contentView.showMeAContact(contactItem.model); //or whatever
    }
    

    This way your ContactItemView doesn’t know anything about the parent views, so it can be more flexible. The downside is it’s a lot of boilerplate code. Maybe someone else will have a cleaner approach, but this does the trick for me.

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

Sidebar

Related Questions

I've got several nested classes, with the following structure: BackupLocation contains list of BackupClients
I've got following view hierarchy: I want ScrollView with nested RelativeLayout to be between
I've got the following situation with ActiveRecord (in Rails 2.3.8): class Order < ActiveRecord::Base
I've got the following model with nested collection var Mdl = Backbone.Model.extend({ initialize: function()
I've got a multi layer nested form User->Tasks->Prerequisites and in the same form User->Tasks->Location
I'm looking for the best practice to solve the following situation: I've got an
I've got an embedded one to many model like the following: class User include
I got following repeating syntax and I want to keep all <h1> that is
I got following code in an XHTML-document and every browser saysit is malformed :(
I got following error... System.NullReferenceException: Object reference not set to an instance of an

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.