0

I need a way to check whether the wallpaper has been favorited in order to know which image to show, a black star, or a yellow star when the user hovers over the image. The easiest way I could think of was using a Dictionary, with the id of the image serving as the key, and a bool representing the favorite status as the value. However, since the id of the image is set as the title, I don't know how in the world I would go about getting the correct value.

Here's a reference to what I'm working on.

How to format a URL.Action() call in JQuery to set a link's href attribute?

I think each image already has most of its attributes filled with information. The class is used for css, the id is used for figuring out selection status, the title has its id from the database.

Community
  • 1
  • 1
Anonymous
  • 57
  • 1
  • 5

1 Answers1

0

It might not be be proper HTML but you can just add whatever attribute you want to a tag.

<a href="..." linkId="12345">My Link</a>

Then you can just use jQuery to get the value by doing ...

$("a").attr("linkId")

I do this all the time for when I need to store some extra data.

CraigW
  • 715
  • 4
  • 5
  • Well, I don't think that would help. I don't think jquery is going to help in this situation, as I have to use TryGetValue on the Dictionary from the Model and I have no way to access the id of the image. I don't think I can populate a value in code from jquery. – Anonymous Jun 15 '11 at 21:59
  • I indeed ended up using a custom attribute to store the favorite status of each image during my iteration through them, and using jquery to check the attribute's value and set the src of the image as necessary. I am still testing to see if my tree traversal amongst the divs and links is accurate. Thanks for the suggestion, if that's what you meant. – Anonymous Jun 15 '11 at 23:08