Use storage to store information about elements. If you have elements that
are related to each other (such as a tab related to the content it displays)
you should store the relationship on the prime element (i.e.
tab.store('section', section);). Store a list of references in your class as
a single array (so a tabs class has an array of tabs) and then use the
stored relationship to fetch the other elements.

Use classes for css styles and for optimizing selectors (i.e. you might have
 a class called "tab" for tabs so it's easy to select $$('tabs')). You
should assign and remove classes for state (tab.selected) that can be
styled.

On Thu, Jul 2, 2009 at 9:29 AM, Eneko Alonso (via Nabble) <
[email protected]<ml-user%[email protected]>
> wrote:

>
> Yeah, I vote for that solution too.
>
> Ideally, you will have all your state variables on the javascript code
> only. There is no need to store anything at all on the html unless you
> are going to loose your references to the dom element at some point.
>
>
>
> On Thu, Jul 2, 2009 at 6:18 AM, gabriel 
> munteanu<jajali...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3196083&i=0>>
> wrote:
> >
> > none.
> > you should keep your elements in a data structure, say an object {},
> > hash, array, etc ...
> > and when you need to apply an action to a certain collection of
> > elements you get it from the data structure.
> > ex: var elements {
> >  tobeclicked: [],
> >  tobecolored: []
> > }
> > and then you populate the 2 arrays , and only after that you play with
> them.
> >
> >
> > On Thu, Jul 2, 2009 at 10:51 AM, Thierry bela 
> > nanga<bna...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3196083&i=1>>
> wrote:
> >> I prefer to use class because it is more flexible,
> >> I can apply things like selector or event delegation, I use storage only
> to
> >> store data.
> >>
> >>
> >> On Thu, Jul 2, 2009 at 12:39 AM, Ryan Florence 
> >> <rpflore...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3196083&i=2>>
> wrote:
> >>>
> >>> I use invalid custom attributes a lot for non-public facing sites (and
> >>> occasionally public facing ones because I love them so much).
> >>> <a blowUpWhat="stuff">Blow stuff up!</a>
> >>> I also use rel a lot if I want to validate.
> >>> I've used store a lot and love it, but haven't used it for this kind of
>
> >>> thing.  I think I'll give it a whirl.
> >>> Ryan Florence
> >>> http://ryanflorence.com/blog
> >>> http://ryanflorence.com/mootools
> >>>
> >>>
> >>> On Jul 1, 2009, at 5:26 PM, Fábio Costa wrote:
> >>>
> >>> i dont use classes for determining what i should do, i use to style and
> to
> >>> mark groups so i can use a class selector to get them.
> >>> I think you should use the storage.
> >>> But thats my own opinion of course, wait for other people opinion.
> >>>
> >>> Fábio Miranda Costa
> >>> Engenheiro de Computação
> >>> http://meiocodigo.com
> >>>
> >>>
> >>> On Wed, Jul 1, 2009 at 6:45 PM, Rolf -nl 
> >>> <plentyofr...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3196083&i=3>>
> wrote:
> >>>>
> >>>> Let's say I want to check an element's value to determine the action
> >>>> that should take place.
> >>>> I could do that with if(el.hasClass('myClass') ...
> >>>> Or I could store a state with el.store and for picking the right
> >>>> action if(el.retrieve('property') == 'whatever') ...
> >>>>
> >>>> I used the work with classes in the past, but now tend to use element
> >>>> storage (looks more like a true scripting approach), and I think it's
> >>>> faster (but that is based on nothing really).
> >>>>
> >>>> What do you use?
> >>>
> >>
> >>
> >>
> >> --
> >> fax : (+33) 08 26 51 94 51
> >>
> >
> >
> >
> > --
> > jgabios
> > http://bash.editia.info
> >
>
>
> ------------------------------
>  View message @
> http://n2.nabble.com/-Moo--Best-practice%3A-using-hasClass-or-store-retrieve--tp3191984p3196083.html
> To start a new topic under MooTools Users, email
> [email protected]<ml-node%[email protected]>
> To unsubscribe from MooTools Users, click here< (link removed) >.
>
>
>


-----
The MooTools Tutorial:  http://www.mootorial.com www.mootorial.com 
Clientcide:  http://www.clientcide.com www.clientcide.com 
-- 
View this message in context: 
http://n2.nabble.com/-Moo--Best-practice%3A-using-hasClass-or-store-retrieve--tp3191984p3197723.html
Sent from the MooTools Users mailing list archive at Nabble.com.

Reply via email to