cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">

    <title>Backbone.Marionette.Export 2.1.6, demo (AMD)</title>
    <meta name="description" content="Backbone.Marionette.Export 2.1.6, demo (AMD)">

    <!-- ATTN Foundation loaded without JS - stay clear of JS-driven widgets, or add the JS setup -->
        ATTN jQuery 1.x is used here, making the demo compatible with oldIE. As a side effect,
        Foundation 5 JS can't be used reliably (requires jQuery 2.x). Stay clear, or switch to
        jQuery 2.x.
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.3/css/normalize.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.3/css/foundation.css">

    <link rel="stylesheet" href="https://cdn.rawgit.com/hashchange/backbone.marionette.export/2.1.6/demo/common.css">
    <link rel="stylesheet" href="https://cdn.rawgit.com/hashchange/backbone.marionette.export/2.1.6/demo/amd/amd.css">

    <!-- Fix HTML5 tags in oldIE and other lacking legacy browsers -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js"></script>

    <script id="collection-template" type="text/x-template">
        <div class="row">
            <p>Collection content, passed to a Marionette.CompositeView template:</p>
            <p>There are <%= items.length %> items in the collection. Exported collection methods tell us that the ID of
                the first item is "<%= items.first.id %>", and the ID of the last item is "<%= items.last.id %>".</p>

    <script id="model-template" type="text/x-template">
        <dt>Model with ID <%= id %></dt>
        <dd><%= someMethod %></dd>
        <dd><%= someMethodWithArgs %></dd>


    <section id="header">
        <h1 class="row">Backbone.Marionette.Export</h1>
        <h2 class="row">Demo (AMD)</h2>

    <section id="main">
        <!-- body content here... -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.1/require.js"></script>
    <script src="https://cdn.rawgit.com/hashchange/backbone.marionette.export/2.1.6/demo/amd/jsbin/map-config.js"></script>
    <script src="https://cdn.rawgit.com/hashchange/backbone.marionette.export/2.1.6/demo/amd/rjs/output/parts/vendor.js"></script>


              // main.js

require( [


], function ( _, Backbone ) {

    var MarionetteBaseView = Backbone.Marionette.ItemView || Backbone.Marionette.View,    // supporting both Marionette 2 and 3

        Model = Backbone.Model.extend( {
            exportable: "someMethod",

            onExport: function ( data ) {
                data || (data = {});                                                // jshint ignore:line
                data.someMethodWithArgs = this.someMethodWithArgs( this.cid );
                return data;
            someMethod: function () {
                return "This is the return value of a method call on model <code>" + this.id + "</code>.";
            someMethodWithArgs: function ( arg ) {
                return "This is the return value of a method call with argument <code>" + arg + "</code> on model <code>" + this.id + "</code>.";
        } ),

        Collection = Backbone.Collection.extend( {
            exportable: [ "first", "last" ]
        } ),

        m1 = new Model( { id: 1  } ),
        m2 = new Model( { id: 2  } ),
        m3 = new Model( { id: 3  } ),

        collection = new Collection( [ m1, m2, m3 ] ),

        DataView = Backbone.Marionette.CompositeView.extend( {
            childView: MarionetteBaseView.extend( {
                tagName: "li",
                template: "#model-template"
            } ),
            childViewContainer: "ul",
            template: "#collection-template"
        } ),

        dataRegion = new Backbone.Marionette.Region( {
            el: "#main"
        } );

    dataRegion.show( new DataView( { collection: collection } ) );
} );

define("local.main", function(){});


Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................