Reputation: 1466
I know there is a way to call fancybox manually with a string of html like so:
$.fancybox("<div>foo</div>")
However, i want to instead pass a jQuery object to the fancybox so i can retain things like .data() and click() events i have already added:
var $fooObj = $("div.foo").data("foo","bar");
$.fancybox($fooObj);
Is this possible somehow?
Upvotes: 4
Views: 7171
Reputation: 1274
Simple Way!!!
$(document).ready(function () {
$.fancybox({
'width': '80%',
'height': '80%',
'autoScale': true,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'iframe',
'href': 'http://www.example.com'
});
});
Upvotes: 0
Reputation: 5698
function LaunchFancyBox(code)
{
jQuery.fancybox({
content: code
});
}
And in the onclick/click:
<a href="#" onclick="LaunchFancyBox('<div>test</div>'); return false;">Launch it baby</a>!
Upvotes: 2
Reputation: 630389
You just need to set it as the content
property in the options you pass into $.fancybox()
, like this:
$.fancybox({
content: $fooObj
});
Upvotes: 9