title: Passing data from one Backbone view to another
body: <p>Lets say I have the following Backbone view which loads two links, one with the anchor text "test1" and the other with the anchor text "test2".</p>
  
  <p>I bind a click event and I get the HTML of the link that was clicked and store it inside the <strong>clickedHtml</strong> variable.</p>
  
  <p>Now, this view is loaded by a Backbone router.</p>
  
  <p>When the user clicks either one of the two links (test1 or test2) another view called "main" will be loaded by the router.</p>
  
  <p><strong>Now, how can I pass the "clickedHtml" variable to that view?</strong></p>
  
  <p><strong>Should I use LocalStorage?</strong></p>
  
  <p><strong>Should I declare it globally like window.clickedHtml?</strong></p>
  
  <p>Is there a better way?</p>
  
  <p>Ty!</p>
  
  <pre><code>// file: views/test.js
              define([
                  'jquery', 
                  'underscore', 
                  'backbone'
              ], function($, _, Backbone) {
  
                  var Test = Backbone.View.extend({
  
                      el : '.test',
  
                      initialize : function () {
  
                          var that = this;
  
                          that.$el.html('&lt;a href="#/main"&gt;test1&lt;/a&gt;&lt;br /&gt;&lt;a href="#/main"&gt;test2&lt;/a&gt;');
  
  
                      },
  
                      events : {
  
                          'click .test a' : 'click'
  
                      },
  
                      click : function (e) {
  
                          var clickedHtml = $(e.target).html();
  
                      }
  
                  return Test;
  
              });
  </code></pre>
  
  <p>Here is my router:</p>
  
  <pre><code>// file: router.js
  
      define([
          'jquery', 
          'underscore', 
          'backbone',
          'views/test',
          'views/main'
      ], function ($, _, Backbone, Test, Main) {
  
          var Router = Backbone.Router.extend({
  
              routes: {
                  '' : 'home',
                  'test' : 'test'
              }
          });
  
          var initialize = function () {
  
              var router = new Router();
  
              router.on('route:home', function () {
  
                  var main = new Main();
  
              });
  
              router.on('route:test', function () {
  
                  var test = new Test();
              });
  
              Backbone.history.start();
          }
  
          return { 
  
              initialize : initialize 
          }
      });
  </code></pre>