Created
July 15, 2013 12:04
-
-
Save magudb/5999445 to your computer and use it in GitHub Desktop.
A CodePen by magudb. Backbone code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require.config({ | |
paths:{ | |
'jquery':'http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min', | |
'underscore':'http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min', | |
'backbone':'http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min', | |
'marionette' : 'http://cdnjs.cloudflare.com/ajax/libs/backbone.marionette/1.0.4-bundled/backbone.marionette.min' | |
}, | |
shim:{ | |
'underscore':{ | |
exports:'_' | |
}, | |
'backbone':{ | |
deps:['underscore','jquery'], | |
exports:'Backbone' | |
}, | |
'marionette' : { | |
deps : ['jquery', 'underscore', 'backbone'], | |
exports : 'Marionette' | |
} | |
} | |
}); | |
define(function (require) { | |
'use strict'; | |
console.log('showing something'); | |
var Marionette = require('marionette'); | |
var Backbone = require('Backbone'); | |
var _ = require('underscore'); | |
var $ = require('jquery'); | |
var App = new Marionette.Application(); | |
App.addRegions({ | |
"gallery": "#galleryContainer" , | |
"mostPopular":"#mostPopularContainer", | |
"flexslider","#flexslider" | |
}); | |
App.module("gallery",function(Mod, App, Backbone, Marionette, $, _){ | |
var galleryModel = Backbone.Model.extend({}); | |
var galleryCollection = Backbone.Collection.extend({model: galleryModel}); | |
var GalleryItemView = Marionette.ItemView({ | |
template:'#galleryTemplate' | |
}); | |
var Gallery = Marionette.CollectionView.extend({ | |
itemView: GalleryItemView | |
}); | |
var GalleryController = Marionette.Controller.Extend({ | |
initialize: function(options){ | |
this.region = options.region | |
}, | |
show: function(){ | |
console.log('showing something'); | |
var collection = new galleryCollection(window.galleryJson); | |
var view = new Gallery({ | |
collection: collection; | |
}); | |
this.region.show(view); | |
} | |
}); | |
Mod.addInitializer(function(){ | |
Mod.galleryController = new GalleryController({ | |
region: App.gallery | |
}); | |
Mod.galleryController.show(); | |
}); | |
}); | |
console.log(App); | |
return App.start(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment