I'd agree that, at this point, the arguments approach could be removed, but mixing bind-time data with trigger-time data makes no sense. They have different uses.
-- Ariel Flesler On Tue, Jun 9, 2009 at 4:55 PM, Ricardo <ricardob...@gmail.com> wrote: > > Yes, but you can only add properties to the event object when > triggering, not alter/extend it's data property. > > $().bind('quack', {a:1}, function(e){ > console.log(e.data.a); // 1 > console.log(e.a); // 3 > }); > $().trigger({type: 'quack', data: {a:2}, a: 3}); > > You'd have to set a second data object in the event obj to safely > iterate over. There is already a property for that, so this seems > overcomplicated. You can already pass other data as arguments, > extending .data on triggering simplifies it all, there's no need for 3 > separate ways of passing data in. > > cheers > -- ricardo > > On Jun 9, 8:59 am, Ariel Flesler <afles...@gmail.com> wrote: > > I think it's ok the way it is now. e.data is for bind-time data and > > the arguments are for trigger-time data. > > > > You can though pass a data object every time you trigger, that is, > > passing it as the event object (must have type) then the data will be > > copied to the event object you'll get. > > > > -- > > Ariel Flesler > > > > On Jun 7, 12:14 pm, sks <simon.shep...@googlemail.com> wrote: > > > > > Hi, > > > I'm a big fan of JQuery, it's totally changed the way I write > > > Javascript. > > > > > One thing it's started to make me do is to use custom events a lot > > > more but something that has struck me is that the event.trigger seems > > > to be somewhat inconsistent with the rest of the api in terms of > > > passing variables around. > > > The specific piece that I'm taking about is the event.data, when you > > > bind things, you can incorporate the data into the call e.g. > > > > > foo.bind("bar", {foo: bar}); - where foo becomes a property of > > > event.data > > > > > but when I trigger things I have to do this: > > > > > foo.trigger("bar", [{foo: bar1}]) > > > > > and the extra data comes in as a second argument to the event being > > > called. > > > > > While this is quite useful functionality, I feel it does depart > > > somewhat from the original, I would expect to pass in an object that > > > could extend and overwrite the original event.data object as well as > > > being able to pass in extra arguments, so it might look something more > > > like this: > > > > > foo.trigger("bar", {foo: bar1}, [{foo2: bar}]; > > > > > where the 2nd argument ({foo: bar1}) overwrites the original property > > > ({foo: bar}) like > > > jQuery.extend({}, event.data, latestData); > > > > > I was wondering if there is any specific reason it is done this way & > > > whether there is anywhere I could suggest that it is altered? > > > > > Thanks > > > > > Simon > > > -- Ariel Flesler http://flesler.blogspot.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---