JQuery Proxy Object Test on JFiddle

I have been digging deeper on JQuery & I really like the proxy usage:
http://jsfiddle.net/mattgre/BNPQ2/

here is the JS Side of it:

var obj = {
name: "John",
test: function() {
$( "#log" ).append( this.name );
$( "#test" ).off( "click", obj.test );
$( "#test" ).off( "click", obj.test2 );
$("#test").off("click", obj.test3);

},
test2: function () {

$( “#op1″ ).append(‘The obj.name===John is’).append(obj.name===”John”);
$(“#op2″).append(‘We know 7==”7” is ‘).append(7 == “7”);

}, test3: function() {

$( “#op3” ).append(“Than surely 7===7 is ==”).append(7===7 );
$(“#op4″).append(‘But is 7===”7” [‘).append(7 === “7”).append(‘] NO result NO’);
}
};

$( “#test” ).on( “click”, jQuery.proxy( obj, “test” ) );
$( “#test” ).on( “click”, jQuery.proxy( obj, “test2” ) );
$(“#test”).on(“click”, jQuery.proxy(obj, “test3”));

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s