title: Backbone: how the trigger function works
body: <p>I'm trying to learn Backbone by looking at an app that someone I know made together with the backbone documentation.  The app has a Bucket model and a Company model (i.e. you put companies in the bucket).  There's one thing in this bit that I'm unclear about, namely, how it uses the <code>trigger</code> method. </p>
  
  <p>Backbone documentation has this to say about <code>trigger</code>:</p>
  
  <h3>trigger <code>object.trigger(event, [*args])</code></h3>
  
  <blockquote>
    <p>Trigger callbacks for the given event, or space-delimited list of events. Subsequent arguments to trigger will be passed along to the event callbacks.</p>
  </blockquote>
  
  <p>In the code I'm looking at, <code>trigger</code> is called like this:</p>
  
  <pre><code>this.trigger("add:companies", Companies.get(companyId));
  </code></pre>
  
  <p><strong>Two questions:</strong></p>
  
  <ol>
  <li><p>The <code>event</code> I assume is <code>add</code>ing a company, but at what point in the code below does that actually happen? Is it when <code>this.set({ "companies": arr }, { silent: true });</code> is run or when <code>this.save();</code> is run (or something else)?</p></li>
  <li><p>If <code>Companies.get(companyId)</code> is the optional argument, what function is it actually passed to? </p></li>
  </ol>
  
  <p><strong>Excerpt from original code</strong></p>
  
  <pre><code>window.Bucket = Backbone.Model.extend({
    defaults: function() {
      return {
        companies: []
      };
    },
  
    addCompany: function(companyId) {
      var arr = this.get("companies");
      arr.push(companyId);
      this.set({ "companies": arr }, { silent: true });
      this.save();
      this.trigger("add:companies", Companies.get(companyId));
    },
  
    // ...
  </code></pre>