Thank you! That is a very full answer. I think I do get it now. And
sorry if I somewhat hijacked this thread...

Michal.

On Dec 29, 7:52 pm, nutron <[email protected]> wrote:
> MooTools has a philosophy that any method that is defined in JS be used
> whenever possible and, when that method is insufficient, that a new method
> be used that replaces it. So, MooTools has setProperty that adds
> cross-browser support and other conveniences for setAttribute.
> Element.set, on the other hand, is just a shortcut method for all the
> others. You can use set to set styles (element.setStyles), events,
> element.addEvents), properties/attributes (element.setProperties), etc. So
> set is kind of an overloaded method with a lot of functionality, but set
> must itself call something to assign these values. Rather than put the
> cross-browser conveniences inside set, MooTools has stand alone methods for
> all of set's functionality (well, most of it - not the custom
> setters/getters those *have* to use set). Thus:
>
> set -> setStyle/setStyles
> set -> addEvent/addEvents
> set -> setProperty/setProperties
>
> set wraps up all these methods into a single interface, but MooTools exposes
> the logic that set uses in methods of their own for greater extensibility
> and access.
>
> I rarely use .set to setStyles - I just use setStyles because on its own it
> doesn't save may bites. I do use set for setProperties. Consider:
>
> el.setStyles({ display: 'block', border: 'none' });
> el.set({ styles: { display: 'block', border: 'none' } }); //harder to type
> out
>
> el.setProperties({ src: '/foo.jpg', alt: 'foo' });
> el.set({ src: '/foo.jpg', alt: 'foo' }); //easier than above
>
> I *do* use set when I want to set numerous things:
> el.set({
>   src: '/foo.jpg',
>   alt: 'foo',
>   styles: { display: 'block', border: 'none' },
>   events: {etc...}
>
> });
>
> I also use it when I create new elements:
>
> new Element('img', {
>   src: '/foo.jpg',
>   alt: 'foo',
>   styles: { display: 'block', border: 'none' },
>   events: {etc...}
>
> });
>
> When you create an element and pass a second argument it's just passed along
> to .set.
>
> So set is a convenience wrapper, but the methods set uses are exposed for
> your use if you care to reference them directly.
>
> On Mon, Dec 29, 2008 at 11:19 AM, Michal-2 (via Nabble) <
> [email protected]<ml-user%[email protected]>
>
> > wrote:
>
> > I think I just about "get" it (sorry... I'm awful) so:
>
> > "set" is a wrapper for
> > "setProperty" which is a wrapper for
> > "setAttribute"
>
> > However, if "set" should always be used, why is "setProperty" a public
> > method?
>
> > Michal.
>
> > On Dec 29, 7:01 pm, nutron 
> > <anut...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089903&i=0>>
> > wrote:
>
> > > My bad, I confused myself.
> > > In my post previously I meant to be talking about setProperty.
> > setAttribute
> > > is a native method:
>
> > >https://developer.mozilla.org/en/DOM/element.setAttribute
>
> > > setProperty is MooTools' wrapper for that method that helps you manage
> > > removing properties (setting them to null) as well as ensuring that
> > > properties that should be booleans (like checked) are set propertly.
>
> > > So set and setProperty are both used to set attributes, but set has
> > > additional functionality and should always be used.
>
> > > On Mon, Dec 29, 2008 at 10:57 AM, Michal-2 (via Nabble) <
> > > ml-user+55915-776128...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089903&i=1>
> > <ml-user%2b55915-776128...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089903&i=2>>
>
> > > > wrote:
>
> > > > What about "setProperty"? The example at
> > > >http://mootools.net/docs/Element/Element#Element:setProperty
> > > > uses it to set img.src . So now there seem to be three ways of setting
> > > > the src of an image:
>
> > > > set
> > > > setAttribute
> > > > setProperty
>
> > > > When should setProperty be used?
>
> > > > Michal.
>
> > > > On Dec 29, 6:45 pm, nutron <anut...@...<
> >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089837&i=0>>
> > > > wrote:
>
> > > > > setAttribute is a specific method for setting an element attribute
> > that's
>
> > > > > native.
> > > > > You can use set and setAttribute to the same effect for, say,
> > img.src,
> > > > but
> > > > > you couldn't use setAttribute for innerHTML because it isn't an
> > > > attribute.
>
> > > > > For all intents and purposes, you should always use .set.
>
> > > > > On Mon, Dec 29, 2008 at 10:37 AM, Michal-2 (via Nabble) <
> > > > > ml-user+55915-776128...@...<
> >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089837&i=1>
> > > > <ml-user%2b55915-776128...@...<
> >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089837&i=2>>
>
> > > > > > wrote:
>
> > > > > > Ah! Thanks, that makes it clear. But what about "setAttribute" in
> > > > > > custom get/setters?
>
> > > > > > Michal.
>
> > > > > > On Dec 29, 6:31 pm, nutron <anut...@...<
> > > >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089764&i=0>>
> > > > > > wrote:
>
> > > > > > > retrieve and store are useful for storing data *on a specific
> > > > element*,
> > > > > > > while getters and setters are applied to *all* elements.
> > > > > > > i.e.
> > > > > > > myElement.store('myeffect', myInstanceOfFxTween);
>
> > > > > > > This is useful for storing a specific property with a specific
> > > > element.
> > > > > > > Getters/setters are useful for defining behavior for all
> > elements:
>
> > > > > > > el.set('tween', options).tween('opacity', 0); <<an instance of
> > > > Fx.Tween
> > > > > > for
> > > > > > > el is *implied*
>
> > > > > > > On Mon, Dec 29, 2008 at 10:10 AM, Michal-2 (via Nabble) <
> > > > > > > ml-user+55915-776128...@...<
> > > >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089764&i=1>
> > > > > > <ml-user%2b55915-776128...@...<
> > > >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089764&i=2>>
>
> > > > > > > > wrote:
>
> > > > > > > > If it's ok, I have related questions: what about creating
> > custom
> > > > > > > > properties returned by "get" and "set": when should it be done?
> > At
>
> > > > > > > >http://mootools.net/docs/Element/Element#Element-Properties
>
> > > > > > > > the example uses the "setAttribute" method: what is that for?
> > When
> > > > > > > > should that be used? Also, the fact that the Tween is returned
> > by
> > > > > > > > "get" rather than "retrieve" confuses me. Why is it get and not
>
> > > > > > > > retrieve? Is it that "get" allows for some custom actions upon
> > > > "get"?
>
> > > > > > > > Michal.
>
> > > > > > > > On Dec 29, 4:30 pm, nutron <anut...@...<
> > > > > >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089676&i=0>>
>
> > > > > > > > wrote:
>
> > > > > > > > > I just went ahead and posted this to my blog, as my answer, I
>
> > > > > > thought,
> > > > > > > > might
> > > > > > > > > be useful to others to read. Includes code examples and
> > whatnot.
>
> > > >http://www.clientcide.com/your-questions/the-difference-between-eleme...
>
> > > > > > > > > On Mon, Dec 29, 2008 at 2:26 AM, stratboy (via Nabble) <
> > > > > > > > > ml-user+89945-1375813...@...<
> > > > > >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089676&i=1>
>
> > > > > > > > <ml-user%2b89945-1375813...@...<
> > > > > >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089676&i=2>>
>
> > > > > > > > > > wrote:
>
> > > > > > > > > > Hi!
>
> > > > > > > > > > after a lot of mootools programming and docs studies, I
> > still
> > > > have
> > > > > > a
> > > > > > > > > > little question:
>
> > > > > > > > > > when should I use get/set and when store/retrieve? Or, in
> > other
>
> > > > > > words,
> > > > > > > > > > what's the best use for get/set and what's the best for
> > store/
> > > > > > > > > > retrieve?
>
> > > > > > > > > > ------------------------------
> > > > > > > > > >  View message @
>
> >http://n2.nabble.com/get-set-vs.-store-retrieve-tp2077828p2077828.html
> > > > > > > > > > To start a new topic under MooTools Users, email
> > > > > > > > > > ml-node+660466-1583815...@...<
> > > > > >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089676&i=3>
>
> > > > > > > > <ml-node%2b660466-1583815...@...<
> > > > > >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089676&i=4>>
>
> > > > > > > > > > To unsubscribe from MooTools Users, click here< (link
> > removed)
> > > > >.
>
> > > > > > > > > -----
> > > > > > > > > The MooTools Tutorial:
> > > >http://www.mootorial.comwww.mootorial.com
> > > > > > > > > Clientcide:  http://www.clientcide.comwww.clientcide.com
> > > > > > > > > --
> > > > > > > > > View this message in context:
>
> > > >http://n2.nabble.com/get-set-vs.-store-retrieve-tp2077828p2089367.html
> > > > > > > > > Sent from the MooTools Users mailing list archive at
> > Nabble.com.
>
> > > > > > > > ------------------------------
> > > > > > > >  View message @
>
> > > >http://n2.nabble.com/get-set-vs.-store-retrieve-tp2077828p2089676.html
> > > > > > > > To start a new topic under MooTools Users, email
> > > > > > > > ml-node+660466-1583815...@...<
> > > >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089764&i=3>
> > > > > > <ml-node%2b660466-1583815...@...<
> > > >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089764&i=4>>
>
> > > > > > > > To unsubscribe from MooTools Users, click here< (link removed)
> > >.
>
> > > > > > > -----
> > > > > > > The MooTools Tutorial:
> >http://www.mootorial.comwww.mootorial.com
> > > > > > > Clientcide:  http://www.clientcide.comwww.clientcide.com
> > > > > > > --
> > > > > > > View this message in context:
>
> >http://n2.nabble.com/get-set-vs.-store-retrieve-tp2077828p2089751.html
> > > > > > > Sent from the MooTools Users mailing list archive at Nabble.com.
>
> > > > > > ------------------------------
> > > > > >  View message @
>
> >http://n2.nabble.com/get-set-vs.-store-retrieve-tp2077828p2089764.html
> > > > > > To start a new topic under MooTools Users, email
> > > > > > ml-node+660466-1583815...@...<
> >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089837&i=3>
> > > > <ml-node%2b660466-1583815...@...<
> >http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2089837&i=4>>
>
> > > > > > To unsubscribe from MooTools Users, click here< (link removed) >.
>
> > > > > -----
> > > > > The MooTools Tutorial:
>
> ...
>
> read more »

Reply via email to