Skip to content

Instantly share code, notes, and snippets.

@jrolfs
Created August 30, 2012 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrolfs/3522496 to your computer and use it in GitHub Desktop.
Save jrolfs/3522496 to your computer and use it in GitHub Desktop.
RequireJS module with 'static private const' (mind the scare quotes)
define(function () {
'use strict';
// ---------- Constants ----------
var MY_STATIC_PRIVATE_CONST = 'only here, every instance, plz don\'t change meh';
var TEMPLATE = '<div></div>';
var MyView = Backbone.View.extend((function () {
// ---------- Private ----------
var _cantTouchThis = 0;
var _template;
return {
//
// -------------------- Init --------------------
//
initialize: function () {
_template = TEMPLATE;
},
//
// -------------------- Control --------------------
//
render: function () {
this.$el.html(_template(data));
return this;
},
// ---------- Accessors ----------
/**
* 'touched it' ಠ_ಠ
*/
getCantTouchThis: function () {
return _cantTouchThis;
},
setCantTouchThis: function (value) {
_cantTouchThis = value;
}
};
}()));
return MyView;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment