Skip to content

Instantly share code, notes, and snippets.

@aaronj1335
Last active December 11, 2015 02:08
Show Gist options
  • Select an option

  • Save aaronj1335/4527927 to your computer and use it in GitHub Desktop.

Select an option

Save aaronj1335/4527927 to your computer and use it in GitHub Desktop.
configurable widget
// this would live in auxl
define([
'vendor/jquery',
'configuration'
], function($, configuration) {
return function(options) {
var name = options.name;
this.configuration =
$.extend(true, this.configuration, configuration[name]);
};
});
// this would be generated server-side similar to the 'strings' module,
// there wouldn't actually be a configuration.js file
define([], function(){
return {
viewwithfourslots: {/*...*/}
}
})
define([
'vendor/underscore',
'gloss/view',
'auxl/asconfigurable',
'module'
], function(_, View, asConfigurable, module) {
var ViewWithFourSlots = View.extend({
defaults: {/*...*/},
configuration: {
// this is where the defaults go
},
init: function() {
/* ... */
}
});
asConfigurable.call(ViewWithFourSlots.prototype, {
name: _.last(module.id.split('/'))
});
return ViewWithFourSlots;
});
@aaronj1335
Copy link
Copy Markdown
Author

updated w/ a note about setting default options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment