OscarGodson/Core.js

".extend()" needs a removal parameter

Closed this issue · 0 comments

In the case you you modify the window object or maybe add an event handler to something outside of your widget, you should be able to setup "uninstall" code. For example...

Core.extend('example',function(){ //on .load()
  $('body').bind('click.example',function(){
    console.log('clicked');
  });
},function(){ //on .remove() / .unload()
  $('body').unbind('click.example');
});

//Would trigger the first function above binding the click
Core.load('example');

$('button').click(function(){
  //Would trigger the second function unbinding the click
  Core.remove('example');
});