Adding a rel-attribute to all a-tags with a specific class

Discussion in 'JavaScript' started by fantasmo, May 31, 2010.

  1. #1
    Hi,

    using this web article http://www.bibblan.com/martin/tinymce-rel-with-lightbox I'm trying to use Lightbox in Tiny_MCE-Editor...so I need to add a rel-attribute to links.

    I was able to make tiny_mce putting a class="lightbox" to an <a>-Link.

    And the second step is to write a Javascript file which looks for <a> with class="lightbox" and adds rel="lightbox". Following the code I tried...

    
    document.observe('dom:loaded', function () {
        $$('a[class^=lightbox]').each(function(s) {
            s.rel = 'lightbox';
        });
    });
    
    Code (markup):
    But that doesn't work, my <a> tags still do only have the class="lightbox" which I chose in tiny_mce.

    Can somebody please check what's wrong with the code?

    PS: And is it also possible to manipulate tiny_mce so that I could enter a kind of prefix to that rel-attribute...like rel="lightbox-myCategoryname"?
     
    fantasmo, May 31, 2010 IP
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    IIRC you can have multiple rel's, so "lightbox catname" would work.
     
    krsix, May 31, 2010 IP
  3. fantasmo

    fantasmo Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You mean that, when i had turned on "advlink"?? ...until now i had not turned on "advlink" because all these selections seemed a bit confusing to me.

    Ok, so now i turned on "advlink" and tried this ...www . tinymce.moxiecode.com/punbb/viewtopic.php?pid=43868#p43868... i changed "advlink"s link.html to have my own names in the "rel"-Pulldown. I uploaded the html and also did login logout at Textpattern and tried again, but the "rel"-Pulldown still looks the same with all these thousand things like "alternate, designate, whatever".

    EDIT:
    Ok now my own rel-pulldown menue woks... strange, maybe I saved that wrong?

    But still....isn't there a way to add via the initalization code an input field, to type the word for the rel-attribute instead of chosing it from a pulldown.
     
    Last edited: Jun 1, 2010
    fantasmo, Jun 1, 2010 IP