1 Reply Latest reply on Sep 3, 2014 10:48 PM by vijayora

    Trouble in opening an URL in modal widow using a custom attribute

    vijayora


      Hi Guys,


      I am in need of you help on following implementation , please help..


      I would like to develop an option for user where i have give an optional custom attribute to user who is posting the discussion , and when this custom attribute is passed with <a> tag, Browser should be opening the given href url in modal window.



      Example:

      <a href="http://www.google.com" someattribute="true">http://www.google.com </a>


      On template.ftl of my theme i have placed following js..but having trouble in accessing "someattribute"


      1. function shouldUrlOpenInModal(link) { 
      2.        var customAtrrtibute= $j(link).attr('someattribute');  // I am having trouble in accessing my custom attribute here - it says undefined
      3.        if (customAtrrtibute != null != -1 && customAtrrtibute == "true")
      4.         { 
      5.             return true;   
      6.          } 
      7.          else
      8.            return false
      9.      } 


      1. $j(document).ready(function() { 
      2.        $j(".jive-link-external-small").each(function(index, link) { 
      3.            
      4.             if (shouldUrlOpenInModal(link)) { 
      5.                  var url = $j(link).attr('href'); 
      6.                  var text=$j(link).html(); 
      7.                  $j(link).attr('modal-url', url); 
      8.                  url = encodeURI(url); 
      9.                  $j(link).attr('href', 'javascript:_myOpenLightbox("'+url+'", "'+text+'");'); 
      10.                  $j(link).removeAttr("target"); 
      11.             }
      12.        }); 
      13.      }); 

      14. function _myOpenLightbox(href, title) { 
      15.         $j(".jive-modal-title-km-article").text(title); 
      16.         $j("#jive-modal-km-article iframe").attr('src', href); 
      17.         $j("#jive-modal-km-article").lightbox_me({closeSelector: ".jive-modal-close, .close"}); 
      18.      } 

      please let me know your thoughts to overcome this issue.

       

      Thanks,

      Vijay