8/10/2010

jQuery FireEvent - A Plugin for firing real DOM events

Or in other words: "How to fire real javascript events". But why? jQuery has already a trigger method for this kind of need ! If you can't get why you have to use this plugin. Try to inject jQuery on this Mootools demo page and run:
jQuery('#v_toggle').click(); //or .trigger('click')
Nothing happens... That's because Mootools & jQuery have their own way to create and fire events. They do this way to support bind namespacing, multiple binding ...

jQuery FireEvent allows you to fire real DOM events. Now, come back to the Mootools page, inject jQuery fireEvent plugin and run:
jQuery('#v_toggle').fireEvent('click');
Even if the v_toggle element was binded with some Mootools magic, because we're firing a real DOM event, all works great ! This plugin is really useful in high conflicted environment where we can't find if an element was binded by one or more javascript libraries.

Fork jQuery FireEvent on GitHub
8/08/2010

[Video] Some experiments with HTML5 Canvas

Here is some experiments I've done on a sunday afternoon with an HTML5 Canvas element and some neat javascript stuff. Enjoy !

8/02/2010

[Snippet PHP] apc_exists for APC < 3.1.4

Problem:


Fatal error: Call to undefined function apc_exists() in xxxx.php on line xx
That's because APC may not be activated or because your APC version is less than 3.1.4.

Fix:


How to know if $ is jQuery ?

Sometime (mostly in highly conflicted environement) you may want to know if $ is really a jQuery alias. Because $ can be an alias for Mootools too (and of course other libs).

Here is a way to detect jQuery:

How to get the call-stack of a javascript function

And to be more precise: How to get the call-stack of a Javascript function everytime she's called without blocking the execution.

From time to time you may want to see every call-stack of a specific function for profiling concerns.

Here is a naive approach:


When executed in firebug, only 1 Error is shown. We miss the alert() and the second call from doAnotherThing.

Solution? Prefer console.log instead of throw:


Now our 2 error (with call-stack) appear in Firebug while the alert('ok') pop-out as expected.
« »
 
 
Made with on a hot august night from an airplane the 19th of March 2017.