1

I know we can have this in 1.4:

$("a").bind({
  click : clickFn,
  mouseover: mouseFn
});

and that is nice and I would like to use it, but it seems like there is no way to pass extra data to events bound this way, it needs to be done the 'old way':

$("a").bind("click", {"some":"data"}, clickFn);

Question:
How can I pass the extra data to my event call backs and bind multiple events in a single bind at the same time?

1 Answer 1

3

You could do something like

$("a").bind({
  click : function() { clickFn.apply(this, [param1,param2,..]); },
  mouseover: function() { mouseFn.apply(this, [param1,param2,..]); }
});

although you would need to make your functions accept parameters in this way ..

[made an update to maintain context]

Sign up to request clarification or add additional context in comments.

1 Comment

good idea. though you are missing the event param now, but i can add that in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.