title: BackboneJS Flash Messages
body: <p>Is there an extension to backbone for Flash Messages? It seems to be a common feature in Web Frameworks (server side at least). There appears to be none, and I attempted to make my own: </p>
  
  <pre><code>class FlashMessenger extends Backbone.Model 
  
      constructor: -&gt;
          @messages = []
  
      # add a message to the messages array
      add: (type, message) -&gt;
          @messages.push 
              type: type
              message: message
  
      # returns all existing messages and clearing all messages
      getMessages: -&gt;
          ret = @messages.slice(0)
          @messages = []
          return ret
  </code></pre>
  
  <p>Now, I was wondering how can I inject them into my views automatically. I will like my messages to show when I use <code>Backbone.Router.navigate()</code> eg: </p>
  
  <pre><code>app.flashMessages.add("success", "Successfully logged in")
  appRouter.navigate("dashboard")
  # flash messages should show when I render the view
  </code></pre>