82mou
12/12/2016 - 2:34 PM

ES5デザインパターン

ES5デザインパターン

var HOGE = HOGE || {};
HOGE.fn = HOGE.fn || {};

// モーダルを開く
HOGE.fn1 = {
    init: function() {
        this.bindEvent();
    },
    bindEvent: function() {
        var self = this;

        this.$target.on('click', function(e) {
            e.preventDefault();
            self.show();
        });
    },
    show: function() {
        console.log('hoge');
    }
};

$(function() {
    HOGE.fn1.init();
});