MarionetteJS (Backbone.Marionette) Playground

A base template to use for building Backbone and Marionette applications. http://marionettejs.com

by Gabriel Vazquez

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://underscorejs.org/underscore.js"></script>
<script src="https://backbonejs.org/backbone.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.marionette/2.4.1/backbone.marionette.min.js"></script>
<header>

  <h1>A Marionette Playground</h1>

</header>
<article id="main"></article>
<script type="text/html" id="sample-template">
  put some content
</script>
<script type="text/template" id="BusinessTableTpl">
  <thead>
    <tr>
      <th>Name</th>
      <th>Address</th>
      <th>Building</th>
      <th>Phone</th>
      <th>Website</th>
      <th>Categories</th>
    </tr>
  </thead>
  <tbody></tbody>
</script>
<script type="text/template" id="BusinessRowTpl">
  < td>
    <%= name %>
      < /td>
        <td>
          <% if (address) { %>
            <%= address %>
              <% } else { %>
                NA
                <% } %>
        </td>
        < td>
          <%
    if (building) { %>
            <%= building %>
              <%
    } else { %> NA
                <%
    } %>
                  < /td>
                    <td>
                      <td>
                        <% _.each(phones, function(phone) { %>
                          <span class="label label-default label-info"><%= phone %></span > <%
    }); %> < /td>
    <td>
        <% if (website) { %>
            <%= website %>
        <% } else { %>
            NA
        <% } %>
    </td > < td > <% _.each(tags, function(category) { %> < span class = "label label-default label-info" > <%= category %> < /span>
        <% }); %>
    </td > < td > Ações < /td>
</script>

JavaScript

// Define the app and a region to show content
// -------------------------------------------

var App = new Marionette.Application();

App.addRegions({
  mainRegion: "#main"
});


// Create a module to contain some functionality
// ---------------------------------------------
var mainView = Marionette.ItemView.extend({
  // template: "#sample-template"
});

App.mainRegion.show(mainView);


// Start the app
// -------------

App.start();