Being careful accesibility, you should't suggest update() images like
that. If you change the src on an image, probably, and before styles,
you should have to change the alternative description. Because of
this, that "update()" method  on images becomes insufficient. To be
nice with everyone, you can complete the suggested wrapper:

Element.addMethods('IMG', {
  setAlt: function(element, alt) {
    return $(element).writeAttribute('alt', alt);
  }
})

$('myEmoticon').setSrc('images/smiling.jpg').setAlt("I'm smiling! :)
");

$('myEmoticon).setSrc('images/sad.jpg').setAlt("I'm sad! :( ");


Regards,
Gonzalo

On 26 ene, 08:12, kangax <[EMAIL PROTECTED]> wrote:
> As Nicolás pointed out, making Element.update change src attribute of
> an image is NOT the way to go. Not only is it unintuitive but
> redefining existent methods could lead to some serious bugs in future
> maintenance/upgrades, etc. If you feel like Element.writeAttribute is
> too verbose, I would suggest to define a simple wrapper:
>
> Element.addMethods('IMG', {
>   setSrc: function(element, src) {
>     return $(element).writeAttribute('src', src);
>   }
>
> })
>
> ...
>
> $('myImage').setSrc('images/blah.jpg');
>
> Best,
> kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to