I use psuedo attributes all the time.  As long as you use them properly
(google "expandos") they are safe.  But then your page won't "validate".
You could also use XML, I think.

<div class="Photo">
   <div class="Title">Walking in the park</div>
   <img src="photos/walkinginthepark.jpg" />
   <div class="Rating">Average Rating:<b>6/10</b></div>
<HasVoted>true</HasVoted>
</div>

But is this any "better" than hidden fields?
I think the main questions are:

1. Is validation critical to you?
2. What is the most manageable for you?

Glen




On Nov 26, 2007 9:59 AM, Wizzud <[EMAIL PROTECTED]> wrote:

>
> Can you not simply add another class to the container div (or the
> image)?
> eg...
>
> <div class="Photo HasVoted">
>    <div class="Title">Walking in the park</div>
>    <img src="photos/walkinginthepark.jpg" />
>    <div class="Rating">Average Rating:<b>6/10</b></div>
> </div>
>
>
> On Nov 26, 2:53 pm, jonhobbs <[EMAIL PROTECTED]> wrote:
> > Just a quick question hopefully.
> >
> > What's the best way of storing settings as part of a chunk of html ?
> >
> > Let me give an example of a photo gallery with lots of photos on the
> > page with the following HTML for each one...
> >
> > <div class="Photo">
> >     <div class="Title">Walking in the park</div>
> >     <img src="photos/walkinginthepark.jpg" />
> >     <div class="Rating">Average Rating:<b>6/10</b></div>
> > </div>
> >
> > Somewhere I would like to store a setting for each Photo which says
> > whether the user has voted on the photo yet or not. This setting would
> > be set originally when the page was created and also would be changed
> > by Jquery scripts when the user rates the photo.
> >
> > The problem is that I can't just create a variable in jscript because
> > I don't know how many photos there will be on each page. I can think
> > of three ways to possibly do it.
> >
> > 1) Use hidden input fields like this....
> >
> > <div ID="Photo-12345" class="Photo">
> >     <input type="Hidden" ID="HasVoted-12345" value="true" />
> >     <div class="Title">Walking in the park</div>
> >     <img src="photos/walkinginthepark.jpg" />
> >     <div class="Rating">Average Rating:<b>6/10</b></div>
> > </div>
> >
> > Bit slow and messy but would work ?
> >
> > 2) Add non-html attributes to the div tag
> >
> > <div class="Photo" HasVoted="True">
> >     <div class="Title">Walking in the park</div>
> >     <img src="photos/walkinginthepark.jpg" />
> >     <div class="Rating">Average Rating:<b>6/10</b></div>
> > </div>
> >
> > Very messy and not allowed HTML ?
> >
> > 3) Using some sort of array in the Jquery code to remember the state
> > of all of the photos on the page.
> >
> > Not sure how I'd create this array when the page is first created by
> > my asp.net code, or update it if partial page updates added or removed
> > photos from the page.
> >
> > There must be a standard, accepted way of doing this ? The in-built
> > toggle function must use something like this to remember the state of
> > stuff you've clicked ?
> >
> > Any help would be really appreciated.
>

Reply via email to