Your welcome! There's also a plugin that uses the classname for saving
data, but I don't see any advantage in it over data() unless you're
generating something server-side: http://docs.jquery.com/Plugins/Metadata

cheers,
- ricardo

On Apr 7, 5:22 pm, Scott <william.scott.ba...@gmail.com> wrote:
> Thanks!  I didn't know about the memory leak issue - I suppose I could
> get around it by modifiying the class name for the "isHighlighted"
> part, and use a Jquery statement to find the highlighted rows (which
> have different class names as well....).  I did it this way to keep
> from searching the entire table (we have some BIG tables) for a
> highlighted row - instead, just check table.isHighlighted and move on
> if false.  If true, you have the rowIndex so there's no iterating
> required.
>
> I really appreciate your help - I'm completely new to JQuery, and it's
> causing a shift in my entire way of thinking... which is good,
> methinks.  If I came off as sounding cocky, it certainly wasn't
> intended.
>
> thanks again.
>
> On Apr 7, 1:14 pm, Ricardo <ricardob...@gmail.com> wrote:
>
> > It doesn't just 'happens to correlate' to an element in the DOM, it is
> > a direct link. Storing values or references to objects in HTMLElement
> > objects can lead to memory leaks. I'd also recommend the use of data
> > ():
>
> > $('table')
> >      .data('isHighlighted', false)
> >      .data('highlightedRowIndex', 0);
>
> > and to retrieve the values:
>
> > $('table').data('isHighlighted');
>
> > cheers,
> > - ricardo
>
> > On Apr 7, 4:35 pm, Scott <william.scott.ba...@gmail.com> wrote:
>
> > > ah... and therein lies an important distinction.  I am not trying to
> > > set HTML attributes on the tables - I am trying to set a property on a
> > > JavaScript object that happens to correlate to a table in the DOM.
> > > Forget the fact that it's tables - it could be any Javascript object.
> > > For instance, the code I have now uses tables:
>
> > > var tables = getElementsByTagName("table");
> > > addTableProperties(tables);
>
> > > function AddTableProperties(tables) {
> > >     var tablesLength = tables.length;
> > >     for (var i = 0; i != tablesLength; i++) {
> > >         var table = tables[i];
> > >         table.isHighlighted = false;
> > >         table.highlightedRowIndex = 0;
> > >       }
>
> > > }
>
> > > but it could just as easily be a "car" object:
>
> > > function AddCarProperties(cars) {
> > >     var carsLength= cars.length;
> > >     for (var i = 0; i != carsLength; i++) {
> > >         var car = car[i];
> > >         car.isDiesel = false;
> > >         car.numDoors = 4;
> > >     }
>
> > > }
>
> > > and my ultimate goal is to have something like:
>
> > > $("table").attr({isHighlighted: false, highlightedRowIndex: 0})
>
> > > See what I mean?  I will read up on the data( ) function - thanks!
>
> > > On Apr 7, 11:28 am, James <james.gp....@gmail.com> wrote:
>
> > > > Also note that 'newProp1' and 'newProp2' are not valid HTML
> > > > attributes. I'm not sure if you really have them existing on your HTML
> > > > page.
>
> > > > If possible, you might want to consider using jQuery's data() to get
> > > > and set data associated with an element:http://docs.jquery.com/Core/data
>
> > > > On Apr 7, 8:21 am, MorningZ <morni...@gmail.com> wrote:
>
> > > > > You're close
>
> > > > > $("table").attr({newProp1: "true", newProp2: "7"});
>
> > > > > although to be honest, your selector or mine doesn't make all that
> > > > > much sense since you would seemingly want to set unique properties on
> > > > > each table, something neither line of code does
>
> > > > > On Apr 7, 1:48 pm, Scott <william.scott.ba...@gmail.com> wrote:
>
> > > > > > I want to add a property (not a class name or id) to all the tables 
> > > > > > in
> > > > > > a web page.  I know I can use $("table") to get all the tables on 
> > > > > > the
> > > > > > page - can I also do this:
>
> > > > > >           $("table").each({newProp1:true, newProp2: 7});
>
> > > > > > so that now table.newProp1 == true and table.newProp2 == 7 ???- 
> > > > > > Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -

Reply via email to