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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:38:07+00:00 2026-05-28T07:38:07+00:00

I have a backbone view – which when called presents a form $(‘#add-offer’).click(function() {

  • 0

I have a backbone view – which when called presents a form

$('#add-offer').click(function() {
    console.log("Here");
    formView = new TB_BB.RequestFormView({model : new TB_BB.Request(), el : '#main-container'});
    formView.render();
});

The view looks like

TB_BB.RequestFormView = Backbone.View.extend({
    initialize : function(){
        this.template = $("#formTemplate"); 
        _.bindAll(this,"render");
    },
    events : {
        "submit #request-form" : "save",
    },
    render : function() {       
        $('#add-offer-button').hide();
        $(self.el).show();      
        var content = this.template.tmpl();
        $(this.el).html(content);
        return this;
    },
    save : function(event){
        console.log("Saved ");      
        event.preventDefault();
    }
});

I have found that every time the
submit #request-form

Event is triggered, it is triggered to EVERY instance of that view – however I thought it would be out of scope.

So for example if I on documentload call

$(function(){
    //create the router...  
    TB_BB.r = new TB_BB.Requests(TB_BB.initialData.requests);
    app = new TB_BB.Router();   
    Backbone.history.start();
    formView2 = new TB_BB.RequestFormView({model : new TB_BB.Request(), el : '#main-container'});
    formView3 = new TB_BB.RequestFormView({model : new TB_BB.Request(), el : '#main-container'});
    formView2.render();
});

And then I click the submit of the form, I see ‘Saved’ 3 times in the console rather than one? should that happen? can I only have one instance of a view?

Any help appreciated

  • 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-28T07:38:07+00:00Added an answer on May 28, 2026 at 7:38 am

    you can have multiple instances of a view,
    and they will be of a separate scope as long as they are working with different dom elements.

    you, on the other hand, pass the dom element to the view, via the el argument, so you specifically tell your 2 or 3 views that they need to manage the same element. thus they will both trigger on your submit button.

    $(function(){
        //create the router...  
        ...
    
        // here you pass #main-container as the element for the view, 
        // so both these two views, will be handeling the same element. 
        // So, if some event is triggered within that scope, like a click on 
        // a submit button inside this scope, both the views will get the event triggered.
        formView2 = new TB_BB.RequestFormView({model : new TB_BB.Request(), el : '#main-container' });
        formView3 = new TB_BB.RequestFormView({model : new TB_BB.Request(), el : '#main-container' });
    
        ...
    });
    

    you can have multiple instances of a view, working separately, you can see examples of that, on the backbone documentation’s example section

    one of the best known examples would be the TODO application (source) where all todo items are instances of the same todoView, each managing click events within their own scope.

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

Sidebar

Related Questions

I have a generic subclass of Backbone.View which has a close event listener. var
I have a Backbone view named Foo which has a scrollbar. When the scrollbar
I have a view called Pannel which is just a background with a close
I have a view. //define View var CreatePollView = Backbone.View.extend({ events: { click #addOption:
I have this structure of views: window.templateLoaderView = Backbone.View.extend({}); window.PopupView = templateLoaderView.extend({ initialize: function
I'm trying to add an event to my backbone view I have setup. I
I have the following views: window.DmnView = Backbone.View.extend({ template: _.template($(#tmpl_dmnListItem).html()), events: { click .getWhois:
I have a Backbone View for a general element that specific elements will be
I have two backbone Views. One is the main view and the other is
I have a view and collection like this: window.DmnView = Backbone.View.extend({ template: _.template($(#tmpl_dmnListItem).html()), events:

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.