JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.js"></script>
<div id="output"></div>
JavaScript
var Grid = function Grid(id) {
var t = this;
// Assign an id to the control.
if (!id) {
// Assign a custom id if the control does not have one.
id = "grid-" + new Date().getTime();
}
t.id = id;
_.each(t.Rows, function (rowFn, key) {
t.Rows[key] = _.bind(rowFn, t);
});
t.Rows.test = 8;
t.init();
};
// Base grid functions.
Grid.prototype = {
init: function init() {
this.Rows.init();
document.getElementById("output").innerHTML += "<br><br>";
},
};
// Additional row-related and row utility functions.
Grid.prototype.Rows = {
test: 9,
init: function init() {
document.getElementById("output").innerHTML += "<br>" + this.Rows.test;
}
};
var x = new Grid("x");
var y = new Grid("y");
var z = new Grid("z");