Created
September 12, 2014 17:47
-
-
Save devfreddy/0e33f1a9a57e150b29e5 to your computer and use it in GitHub Desktop.
Marionette App Template
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
$(window).load(function () { | |
if (!this.cure || typeof this.cure !== 'object'){ | |
this.cure = {}; | |
} | |
this.cure.donate = (function () { | |
'use strict'; | |
var MyApp = new Backbone.Marionette.Application(); | |
MyApp.onStart = function () { | |
}; | |
MyApp.addInitializer(function () { | |
$( document ).ajaxSend(function(event, request) { | |
request.setRequestHeader("wp-nonce", data.wp_nonce); | |
request.setRequestHeader("user-id", data.user_id); | |
}); | |
}); | |
MyApp.addRegions({ | |
region1: '#selector' | |
}); | |
MyApp.module('Module Name', function (Mod, MyApp, Backbone, Marionette, $, _) { | |
Mod.addInitializer(function () { | |
Mod.controller = new Controller(); | |
}); | |
var Controller = Backbone.Marionette.Controller.extend({ | |
initialize: function () { | |
var user, | |
userView; | |
user = new UserModel(Backbone.Syphon.serialize($('#my-account-form').get(0))); | |
userView = new UserView({ model: user}); | |
MyApp.userEdit.show(userView); | |
} | |
}); | |
var MyModel = Backbone.Model.extend({ | |
url: '', | |
defaults: { | |
} | |
}); | |
var MyItemView = Backbone.Marionette.ItemView.extend({ | |
template: "#selector", | |
events: { | |
}, | |
modelEvents: { | |
"sync": "render" | |
}, | |
templateHelpers: { | |
myTemplateHelperFunction: function () { | |
return ''; | |
} | |
} | |
}); | |
var MyCollectionView = Backbone.Marionette.CompositeView.extend({ | |
template: '#selector', | |
tagName: 'ul', | |
className: '', | |
childView: MyItemView, | |
childViewContainer: '#', | |
//emptyView: '', | |
initialize: function () { | |
}, | |
events: { | |
"click": function () { | |
MyApp.vent.trigger(''); | |
} | |
} | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment