I have the following code on my page to open a FancyBox window anytime a user clicks a link with class=iframe.
$.noConflict();
$(document).ready(function () {
$("a.fancybox").fancybox({
'width': '75%',
'height': '75%',
'autoScale': false,
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'type': 'iframe'
});
});
My problem is that this doesn't work when that link is nested inside of an asp panel. I tried implementing the answer found here Rebinding events in jQuery after Ajax update (updatepanel). The result is that the FancyBox fires correctly until the panel content is changed.
Not sure if it's relevant, but the content inside of the asp panel is a DataList that gets refreshed using ajax whenever the row selection in a RadGrid changes. The link that I want to call the FancyBox was initially inside of the DataList itemtemplate and then I moved it ouside of the DataList, but it is still inside of the asp panel. I'd like for it to stay inside of the asp panel and therefore am trying to find the appropriate event for my JQuery to respond to.
I've also tried nesting the JQuery inside of a function that responds to the RadGrid RowClick event. That did not work either.
What should I try next?
EDIT Based on the answer below it doesn't appear there is a great way of accomplishing this. So, here's another way of potentially skinning a cat. Instead of using a hyperlink inside of the panel maybe I can add a button to an existing toolbar that I have on the page. I already fire a javascript function from the toolbar that dynamically sets the NavigateURL and opens it in a new window. Here's an example of that function below. The first IF statement shows how I currently have it implemented setting the URL and launching it in a RadWindow. The second IF statement is where I'm thinking I can fire the FancyBox to open with the relevant URL. Perhaps this will get around the ajax issue raised in my original question. Does anyone know how to make this work? Can I cause a FancyBox to open from Javascript?
function click_handler(sender, args) {
var button = args.get_item();
buttontext = button.get_text();
if (buttontext == "Request Return") {
//This is an example that uses a RadWindow instead of FancyBox
var mastertable = $find("<%=RadGrid1.ClientID %>").get_masterTableView();
var PackageID = mastertable.get_dataItems()[0].getDataKeyValue("PackageID");
var oManager = GetRadWindowManager();
oManager.open("Return.aspx?ID=" + PackageID, "RadWindow1");
return false;
}
if (buttontext == "Open My Fancy Box") {
//do something here to a dynamic URL in FancyBox
}