Jump to content
Sign in to follow this  
KillGorack

Fancybox Links not working

Recommended Posts

Posted (edited)

Working with some older php code, and Fancybox 2.1.5

We moved to getting js/css from CDNJS using:

<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.js" integrity="bla bla bla" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.css" integrity="bla bla bla" crossorigin="anonymous" />

Now the links within the fancy box, seems to be reloading the box again instead of following the link. I pretty sure it's a version issue, just cant get it to work..

<?php

   if(isset($pop)){
    if($pop['shw'] == true){
   //========================================================
   // A message with a forward button ot two
   //========================================================
     if($pop['typ'] == "MsgFwd"){
      echo "<script type=\"text/javascript\">";
        echo "$(document).ready(function() {";
          echo "$(\"#show_pop_message\").fancybox().trigger('click');";
        echo "});";
      echo "</script>";
      echo "<div id=\"show_pop_message\" style=\"display:none;\">";
      echo "<div class=\"cont_login\">";
      echo "<table cellpadding=\"2\" width=\"100%\" border=\"0\" cellspacing=\"0\">";
      echo "<tr>";
      echo "<td colspan=\"2\"><div class=\"text5\">".$pop['ttl']."</div></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td colspan=\"2\"><hr class=\"allform_div\"></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td style=\"vertical-align: text-top;\"><img src=\"".$pop['ico']."\" style=\"margin-right:10px;\"></td>";
      echo "<td><div class=\"text7\">".$pop['msg']."</div></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td colspan=\"2\"><hr class=\"allform_div\"></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td><div class=\"text6\" style=\"text-align:left;\">".$pop['nte']."</div></td>";
      echo "<td align=\"right\">";
      echo "<a href=\"".$pop['fwda']."\" id=\"NULL\"><img src=\"".$pop['btna']."\" style=\"margin-bottom:-5px; text-align:right;\"></a>";
      echo "</td>";
      echo "</tr>";
      echo "</table>";
      echo "</div>";
      echo "</div>";
   //========================================================
   // Just a message (Ok and it goes away)
   //========================================================
     }elseif($pop['typ'] == "MsgOk"){
      echo "<script type=\"text/javascript\">";
      echo "window.jQuery(document).ready(function() {";
      echo "$.fancybox.open('#unlnkForm');";
      echo "});";
      echo "$(':button').click(function() {";
      echo "parent.$.fancybox.close();";
      echo "})";
      echo "</script>";
      echo "<div id=\"unlnkForm\" style=\"display:none;\">";
      echo "<div class=\"cont_login\">";
      echo "<table cellpadding=\"2\" width=\"100%\" border=\"0\" cellspacing=\"0\">";
      echo "<tr>";
      echo "<td colspan=\"2\"><div class=\"text5\">".$pop['ttl']."</div></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td colspan=\"2\"><hr class=\"allform_div\"></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td><img src=\"".$pop['ico']."\" style=\"margin-right:10px;\"></td>";
      echo "<td><div class=\"text7\">".$pop['msg']."</div></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td colspan=\"2\"><hr class=\"allform_div\"></td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td><div class=\"text6\" style=\"text-align:left;\">".$pop['nte']."</div></td>";
      echo "<td align=\"right\">";
      echo "<a href=\"javascript:parent.$.fancybox.close();\"><img src=\"".$pop['btna']."\" style=\"margin-bottom:-5px; text-align:right;\"></a>";
      echo "</td>";
      echo "</tr>";
      echo "</table>";
      echo "</div>";
      echo "</div>";
     }
   //========================================================
    }
   }

?>

using that mess up there with:

      $pop = array(
       "shw" => true,
       "typ" => "MsgFwd",
       "ttl" => "Success!",
       "msg" => "Thanks your changes have been made, please press the OK button below.",
       "ico" => "sty/img/ico/alert.png",
       "nte" => "",
       "fwda" => $lnk,
       "btna" => "sty/img/btn/ok.png"
      );

Any ideas on how to get the links within the box to work?

Edited by KillGorack

Share this post


Link to post
Share on other sites

I have a working solution, this seems to work..

From

<script type="text/javascript">
 $(document).ready(function() {
  $("#show_pop_message").fancybox().trigger('click');
 });
</script>

To

<script type=\"text/javascript\">
 window.jQuery(document).ready(function() {
  $.fancybox.open('#show_pop_message');
 });
</script>

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.