Implementing jQuery’s “live” binder with native Javascript

Here’s a simple example: function live(eventType, elementId, cb) { document.addEventListener(eventType, function (event) { if (event.target.id === elementId) { cb.call(event.target, event); } }); } live(“click”, “test”, function (event) { alert(this.id); }); The basic idea is that you want to attach an event handler to the document and let the event bubble up the DOM. Then, check … Read more

Should WebSocket.onclose be triggered by user navigation or refresh?

The unexpected behavior is due to the way in which Firefox and Chrome handle the closing of a Websocket. When the page is refreshed, both browsers close the connection, however, Firefox will execute your onclose code, while chrome closes the connection and skips straight to re-loading the new page. So yes, I confirm this strange … Read more

Why *should* we use EventHandler

There actually is a good reason for requiring the second argument to derive from EventArgs if your fully-trusted code hosts third-party code as partially-trusted. Because the callback to the event handling delegate is done in the context of the raising code and not the third party code, it is possible for malicious third-party code to … Read more

Are Click, Tapped, and PointerPressed synonymous in WinRT-XAML?

Click is there for backwards compatibility, and is essentially the same as Tapped. Tapped is a “high level gesture” that will translate automatically to a click, tap, pen press, etc. and is what I would recommend to use. PointerPressed is not what you want. Here’s why: if I press and hold, the PointerPressed event will … Read more

EventBus/PubSub vs (reactive extensions) RX with respect to code clarity in a single threaded application

The following is what I see as benefits of using reactive event streams in a single-threaded synchronous application. 1. More declarative, less side-effects and less mutable state. Event streams are capable of encapsulating logic and state, potentially leaving your code without side-effects and mutable variables. Consider an application that counts button clicks and displays the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)