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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:52:35+00:00 2026-06-15T01:52:35+00:00

I understand how custom events work in Backbone and how to trigger them, but

  • 0

I understand how custom events work in Backbone and how to trigger them, but I’m having trouble understanding when exactly to use them and what purpose they serve over just calling the function directly.

e.g.

var MyView = Backbone.View.extend({
    tagName: 'div',
    className: 'myview',

    initialize: function() {
        this.model.on("mycustomevent", this.doSomething, this);
    },

    doSomething: function() { 
         console.log('you triggered a custom event');
    }

});

If I am not mistaken, The doSomething method can be called by using this.model.trigger("mycustomevent") within other methods, but can be also called directly with this.doSomething()

Outside the view, it can be called similarly with

var myview = new MyView({model:somemodel});

myview.model.trigger("customevent");

myview.doSomething();

What I am confused about is why not forgo the the custom event and just call the method directly when you need it? Any example uses would be greatly 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-06-15T01:52:36+00:00Added an answer on June 15, 2026 at 1:52 am

    You might want to add multiple handlers in different places in the code, f.ex:

    this.model.on("mycustomevent", this.doSomething, this);
    
    // ... and somewhere else you add an anonymous function
    this.model.on("mycustomevent", function() {
        console.log('do something');
    });
    

    Then when you trigger the event, it will execute all handlers. You can also use off to unbind/manage individual or multiple handlers.

    If you are asking about a generic explanation of the event pattern (also called observer pattern, publish/subscribe, etc…), you should probably look for a more in-depth article or book.

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

Sidebar

Related Questions

I can easily understand how to use custom events in pure C# code, but
I understand how to trigger and listen for custom events. I can't figure out
I'm trying to get my head around custom events. I understand how to register
I see other questions for how to create custom events, but I'm not clear
I'm trying to trigger my own custom events as global events, so that anything
I thought I understand the events in C#. That sometimes they are used if
So I understand how to make a custom form class return one instance of
I understand that according to the HTML specification, it's invalid to add custom attributes
I don't understand, I have a toolbar with buttons bind to custom commands. Also
I'm reading this documentation article about Custom Annotations in Doctrine . I understand that

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.