コンテキストの定義
ステートフルJavaScript4.2
by FiNGAHOLiC
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<div id="view">
<div class="assets">foobar</div>
</div>
JavaScript
(function($){
var mod = {};
mod.load = function(func){
$.proxy(func, this)();
};
mod.load(function(){
console.log(this);
this.view = $('#view');
});
mod.assetsClick = function(){
console.log('click');
};
mod.load(function(){
this.view.find('.assets').click(
$.proxy(this.assetsClick, this)
);
});
}(jQuery));