Im tring to use the observer pattern in javascript with jQuery, but trigger and binding don't work. How can I do this to get a "warning (" notify related "); running? Thanks;)
(function($){ var NoteApp = function(){ var self = this; this.notifications = []; this.EVENT = { NOTIFY: 'notify' }; this.button = { ask_number: $('#ask-number'), ask_email: $('#ask-mail'), ask_out: $('#ask-out') }; var Button = function(){ }; var Data = function(app){ $(app.notifications).bind(app.EVENT.NOTIFY, function(){ alert('notify binded'); }); }(this); var UI = function(app){ app.button.ask_number.bind(app.EVENT.NOTIFY, function(){ alert('notify 2'); }); app.button.ask_number.click(function(){
source share