This is one of the reasons I had suggested making the scope-setting capability an external API, not trying to shim in into a few existing APIs. Your [obj, handler] array is much like calling:
$.hitch.apply(this, [obj, handler]) from my ubertiny hitch plugin: http://higginsforpresident.net/js/static/jq.hitch.js So anywhere you pass a function(){} you can pass a hitched function. All the following syntax examples would work: $("#id").bind('click', $.hitch(myobj, function(){ ... }) ); $("#id").bind('click', $.hitch(myobj, myobj.foo) ); $("#id").bind('click', $.hitch(myobj, "foo") ); While preserving API compatibility for older style calls. It also allows the use of the API outside of events/bind. setTimeout($.hitch(this, function(){ ... }), 1000); And so on. Granted, typing $.hitch() is more than simply passing the params you'd want to hitch natively, but I find it being explicit makes more sense to me and is less magic while still providing a great bit of functionality to the users who grok it. Regards, Peter xwisdom wrote: > Hello, > > I've looked at the event scoping feature on 1.4 roadmap and I'm > wondering if we really need to add a scope parameter? > > Here's what I would like to propose as a solution that would not break > with existing designs: > > $("#elmentid").bind('click', [obj, fn]); > $("#elmentid").bind('click', data, [obj, fn]); > > the scoped callback would take the form [obj, fn] > > example: > > var myobj = { > property: "value", > saveHandle: function() { > // code here > } > }; > > var handler = function() { > // code here > } > > $("#elementid").bind('click',[myobj,handler]); // callback handler > with myobj scope > $("#elementid").bind('click',[myobj,"saveHandle"]); // callback > saveHandle on myobj > $("#elementid").bind('click',[myobj,myobj.saveHandle]); // callback > saveHandle on myobj > > Callback with data and scope > > var data = {property1:"value1", property2:'' } > $("#elementid").bind('click', data, [myobj,"saveHandle"]); // callback > saveHandle on myobj > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---