views:

18

answers:

1

I'm trying to add multiple jQuery data entries to a single element.

I suspected that the following would work

jQuery('td.person#a'+personId).data('email',thisPerson.email).data('phone',thisPerson.phone);

However, I am getting nothing but errors when I do this.

jQuery('td.person#a'+personId).data('email',thisPerson.email);
jQuery('td.person#a'+personId).data('phone',thisPerson.phone);

is there another way to get more than one data entry on an element? Hopefully chained?

+5  A: 

You can pass an object into .data(), like this (broken so to prevent horizontal scroll)

jQuery('td.person#a'+personId)
      .data({email:thisPerson.email, phone:thisPerson.phone});

To answer your question though, yes it should be chainable, if you post what errors you were getting that would help see why it isn't working.

Nick Craver
Thanks Nick, I'll move it to an object. The error I'm getting in firebug really doesn't provide any data other than 'jQuery(
pedalpete