0

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.

1 Answer 1

1

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

"Drupal.settings.baseUrl"

/* 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"))
                        {
                            if($(this).parent().hasClass('lightbox-processed')){
                                    jQuery(this).removeClass("external");
                            }else{
                                    jQuery(this).addClass("external");
                                    var targ = "_blank";
                                    jQuery(this).attr("target", targ);

                            }
                        Drupal.attachBehaviors();
                        }
                    }
      });
   }
  };

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 and acknowledge you have read our privacy policy.

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