Skip to content
Permalink
Browse files
Missed the case of bind in the new attr multi-setter.
  • Loading branch information
jeresig committed Dec 10, 2009
1 parent 474d814 commit ecdcda870c70c262ec3198e067dd06e847f682dd
Showing 1 changed file with 2 additions and 1 deletion.
@@ -211,7 +211,8 @@ jQuery.extend({
data: true,
width: true,
height: true,
offset: true
offset: true,
bind: true
},

attr: function( elem, name, value ) {

3 comments on commit ecdcda8

@padolsey
Copy link
Contributor

@padolsey padolsey commented on ecdcda8 Dec 10, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How exactly would one use attr({bind:...}) here? "Bind" needs to be passed, at minimum, two arguments -- this only works for one. Might be worth allowing multiple arguments to be passed via an array:

$(elem).attr({
bind: ['click', function(){}]
});

Although, tbh, I doubt that "bind" would be very useful in this context.

@jeresig
Copy link
Member Author

@jeresig jeresig commented on ecdcda8 Dec 10, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, .bind() now accepts an object. So you can do:

$("<div/>").attr({
  "class": "test",
  html: "<b>foo</b>",
  css: { color: "red", background: "black" },
  bind: { click: ..., mouseover: ... }
});

Naturally the case of a regular bind won't work here, it's strictly for the object case.

@padolsey
Copy link
Contributor

@padolsey padolsey commented on ecdcda8 Dec 10, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, cool, I didn't see that change...

Please sign in to comment.