Skip to content

Commit

Permalink
Missed the case of bind in the new attr multi-setter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeresig committed Dec 10, 2009
1 parent 474d814 commit ecdcda8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/attributes.js
Expand Up @@ -211,7 +211,8 @@ jQuery.extend({
data: true,
width: true,
height: true,
offset: true
offset: true,
bind: true
},

attr: function( elem, name, value ) {
Expand Down

3 comments on commit ecdcda8

@padolsey
Copy link
Contributor

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

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

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.