Skip to content

Instantly share code, notes, and snippets.

@elisechant
Last active December 30, 2015 20:29
Show Gist options
  • Save elisechant/7880805 to your computer and use it in GitHub Desktop.
Save elisechant/7880805 to your computer and use it in GitHub Desktop.
JS Module Prototype Skeleton
var MyNamespace = MyNamespace || {};
(function ($) {
"use strict";
var $w = $(window),
BU = MyNamespace.Util
;
MyNamespace.ArticleItem = function(el) {
this.el = '#page-test';
var me = this
, $scope = $(me.el)
;
if ( !!( $scope && $scope.length ) == false ) {
// throw "No element or no valid element given for the API_test item";
return;
}
me.initEvents();
// assign instance properties
me.el = el;
me.id = el.attr('id');
// init each
// initialises the prototype.init
$($.proxy(me.init, me));
};
MyNamespace.ArticleItem.prototype = {
el: null,
id: '',
init: function() {
console.log(this.el)
}
};
}(jQuery));
// instantiate
// loop through for all item
var item = new MyNamespace.ArticleItem( item );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment