JSFiddle - React, Tailwind, and code Playground
HTML
<button id="thingy" type="button">
Alert thingy
</button>
<button id="another" type="button">
Alert another
</button>
JavaScript
var app = {
init: function() {
// typical things here
var _this = this; // so we can access the app object in other functions
$('#thingy').click(function(){
alert(_this.options.thingy.call(_this));
});
$('#another').click(function(){
alert(_this.options.getAnother.call(_this));
});
},
options: {
thingy: function() {
return this.getThingy();
},
getAnother: function() {
return 'another ' + this.options.thingy.call(this);
},
},
getThingy: function() {
return 'thingy';
}
};
$(document).ready(function () {
app.init();
});