$('.selector').prepOverlay()
from plone.app.jquerytools
works fine when binding a popup to 'onClick' and load it's content from the url provided by one of the href/src/rel attributes.
<a class=".selector" href="link/to/@@view">link</a>
i've got the usecase where i load my content via ajax manually, check it for certain conditions and if these are met i want to show the content returned by the ajax request in an overlay:
jQuery.ajax({
type: 'GET',
url: portal_url + '/@@my-popup',
success: function(r) {
if (r != '') {
// show Overlay
}
}
});
what i currently do to show the overlay is:
create a link item, bind an overlay to it and open it
var link = $('<a href="' + portal_url + '/@@my-popup"></a>')
link.prepOverlay({
subtype:'ajax',
});
link.click();
however, this results in two requests for '/@@my-popup'
is there a nicer way to get arbitrary content into the overlays created with prepOverlay?
Nope, unfortunately not.
If you look closer to the prepOverlay
function, you see the following line:
// be promiscuous, pick up the url from
// href, src or action attributes
src = o.attr('href') || o.attr('src') || o.attr('action');
This means you're not able to trigger the overlay, without having a element with href, src or action attribute.
You may write your own prepOverlay method, wich does not iterate over some elements, but takes a specific url as param.