I'm using this module External Link module which adds "ext" as a class to any anchor tag matching the regex defined via the admin UI provided by the module. I then bind a click event to trigger colorbox for anchor tags with the "ext" tag. Now my issue is, any anchor tags added to the colorbox container are also being added a class "ext".

I understand that this has to do with Drupal.behaviors attach method implemented in the contrib module, but how do I "detach" this behaviors from my custom js file? Specifically for the links within the modal container.


we faced the same issue here we are using lightbox module what we did is we dint used any extra module in common we wrote a Behaviour to add a external class and added condition to when colorbox is added remove external class

Define your base URL in any module in it


/* external links*/
 Drupal.behaviors.external_link = {
    attach: function (context, settings) {
      $("body .view-content a").once(function() {
                    var anchorlink = '';
                    anchorlink = jQuery(this).attr('href');
                    if(anchorlink != "#" && !$(this).hasClass('lightbox-processed'))
                        if(!(anchorlink.lastIndexOf('http') == -1) && anchorlink.lastIndexOf(Drupal.settings.baseUrl) == -1 && !jQuery(this).hasClass("external"))
                                    var targ = "_blank";
                                    jQuery(this).attr("target", targ);


instead of lightbox-processed replace your class hope this will help you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.