Created
August 30, 2012 04:52
-
-
Save jrolfs/3522496 to your computer and use it in GitHub Desktop.
RequireJS module with 'static private const' (mind the scare quotes)
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
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