I have a php file which renders a phpgrid. In one column I have a link that I need to have open a different php file, but in a modal window rather than a new browser window.
This is the code which builds the column, where the link is located.
("object_details.php)
$col = array();
$col["title"] = "Location List";
$col["name"] = "locations";
$col["width"] = "35";
$col["align"] = "center";
$col["search"] = false;
$col["sortable"] = false;
$col["link"] = 'javascript:window.open("objects/present_in.php?o_id=$o_id")';
$col["default"] = "DETAILS";
$cols[] = $col;
(present_in.php)
$col = array();
$col["title"] = "Location";
$col["name"] = "locations";
$col["width"] = "15";
$col["align"] = "center";
$col["search"] = false;
$col["sortable"] = false;
$col["default"] = "Locations where this object is present";
$cols[] = $col;
currently it opens a new browser window and keeps the original open with no content. How can I call a function that I can use to open a simple modal, or fancybox to display the grid in php file "present_in.php"?
I can write the function, I am just unsure how to properly call the function from the grid column.
You can refer demos/integration/fancy-box.php
# class='fancybox' to open image in fancybox
$col["default"] = "<a class='fancybox' href='http://ssl.gstatic.com/ui/v1/icons/mail/logo_default.png'><img height=25 src='http://ssl.gstatic.com/ui/v1/icons/mail/logo_default.png'></a>";
$cols[] = $col;
You can replace <img> and href with your text and php page.
You also need to iniclude fancybox resource and JS to attach fancybox (as in demo)
If you are using free version,
$col["link"] = 'javascript:window.open("http://www.google.com/?q={name}","newwind","height=500,width=800"); void(0);';
Instead of window.open … you can try calling:
jQuery.fancybox.open({href: "abc.php"});
Here are fancy box includes.
<!– Add fancyBox main JS and CSS files –>
<link type="text/css" rel="stylesheet" href="//cdn.jsdelivr.net/fancybox/2.1.4/jquery.fancybox.css" />
<script type="text/javascript" src="//cdn.jsdelivr.net/fancybox/2.1.4/jquery.fancybox.js"></script>
Thank you Abud, I should have mentioned I am having difficulty with the style of the fancybox, and was hoping to use jQuery to override inline size attributes, and that was why I wanted to call a function, is that not possible here?
I am not using the free version, but I will look at the integrating fancybox demo. Thanks