Skip to content

Instantly share code, notes, and snippets.

@bobholt
Created May 15, 2013 00:31
Show Gist options
  • Save bobholt/5580832 to your computer and use it in GitHub Desktop.
Save bobholt/5580832 to your computer and use it in GitHub Desktop.
Keel Module Template Files
/**
* app/framework/Message
*
* Enumeration of messages
*
* @author Bob Holt
*/
define([
'keel/Message',
'underscore'
],
function(frameworkMessage, _) {
'use strict';
var message = _.extend({
// App-specific Messages
}, frameworkMessage);
return message;
});
/**
* app/services/AccountService
*
* Proxy for resource on the server.
*
* @author Bob Holt
*/
define(['app/domain/Repository'],
function(Repository) {
'use strict';
// Module level variables act as singletons
var _url = '/someURL';
return {
postMethod: function(data, successCallback, errorCallback) {
$.ajax({
url: _url,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(data),
success: successCallback,
error: errorCallback
});
},
putMethod: function(data, successCallback, errorCallback) {
$.ajax({
url: _url,
type: 'PUT',
contentType: 'application/json',
data: JSON.stringify(data),
success: successCallback,
error: errorCallback
});
},
deleteMethod: function(doneCallback, failCallback) {
$.ajax({
url: _url,
type: 'DELETE',
success: doneCallbacks,
error: failCallbacks
});
}
};
});
/**
* app/widgets/keel/KeelWidget
*
* @author Bob Holt
*/
define(
[
'keel/BaseView',
'text!app/widgets/keel/KeelTemplate.html'
],
function( BaseView, KeelTemplate ) {
'use strict';
return BaseView.extend({
tagName: 'div',
// elements: [],
template: {
name: 'KeelTemplate',
source: KeelTemplate
}//,
// events: {
// },
// postRender: function() {
// this.addChild({
// id: 'AnotherWidget',
// viewClass: AnotherWidget,
// parentElement: this.$el,
// options: {}
// });
// }
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment