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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:15:57+00:00 2026-05-31T07:15:57+00:00

I have a parent backbone view which creates a new backbone view in its

  • 0

I have a parent backbone view which creates a new backbone view in its render method.

var appView = Backbone.View.extend({
    ...
    render: function() {
        preview = new previewDataView({model: model, el: $el.find('.preview-container')});
    }
});

I want to be able to trigger a custom event in appView and have previewDataView bind to it — is this possible? previewDataView did not receive the event when I tried that. Thoughts?

  • 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-31T07:15:58+00:00Added an answer on May 31, 2026 at 7:15 am

    Two ways I think you could accomplish this. First, pass the parent into the child view. Second, create an eventAggregator that handles event firing.

    FIRST:

    You could pass the appView into the previewDataView as an options.

    preview = new previewDataView({ // your options, 'parent':this });
    

    In your previewDataView you would bind to the parent custom event like so:

    this.parent = this.options.parent;
    this.parent.bind('eventName', this.onEvent, this);
    

    SECOND: (Just learned this technique)

    You could create an eventAggregator that helps your views subscribe to and unsubscribe for events meant for each other. Here is a good answer that explains this in detail on Stack: fire an event from one view to another in backbone

    In the comments, @Brian Genisio takes it a step further to include this in his code:

    Backbone.View.prototype.eventAggregator = _.extend({}, Backbone.Events);
    

    Have this run in the start of your code and every view will have access to eventAggregator which will be your central hub for events that need to be triggered and received across views. You’d use it like this:

    // Parent View
    this.eventAggregator.trigger('someEvent');
    
    // Child View
    this.eventAggregator.bind('someEvent', this.function, this);
    

    With this, you don’t have to explicitly pass reference between views that need access to each other for event triggering and listening. This method has come in QUITE handy for me. 🙂

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

Sidebar

Related Questions

I have this: var SomeNamespace = { Model: Backbone.Model.extend(), View: Backbone.View.extend({ model: new this.Model,
I have the following code: var GoalPanelView = Backbone.View.extend({ // Bind to the goal
I have a parent thread (non-UI) which creates some child threads to do some
I have a parent thread (non-UI) which creates some child threads to do some
I have a view and collection like this: window.DmnView = Backbone.View.extend({ template: _.template($(#tmpl_dmnListItem).html()), events:
I have implemented a simple close() method for all the Backbone views which disposes
I have a backbone view that calls to a sub-view: lr.MapView = Backbone.View.extend({ el:
I have the following views: window.DmnView = Backbone.View.extend({ template: _.template($(#tmpl_dmnListItem).html()), events: { click .getWhois:
I have the following Parent Object: Context = { ContextModel: Backbone.Model.extend({ //model Code }),
I have the following model: var Soq = Backbone.model.extend({ default:{ 'name': 'something' , 'parents':

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.