I am doing a GeoMap of some blog activity and new comments get added to the map with data from a socket. Now I want these comments to link to the blogpost, but in a Fancybox iframe style.
As the links does not exists yet I am having trouble to get fancybox to init these.
I want to be able to do something like:
<a href="http://domain/url/to/post" class="fancybox iframe" onclick="trigger_the_link_in_fancybox_iframe">
This is the code I have for the socket data so far:
var socket = io.connect('http://debug.dk:1000')
function geodata(content)
{
var jsonstring = jQuery.parseJSON(content);
var lat = jsonstring.lat;
var long = jsonstring.lng;
// Add marker
var myLatlng = new google.maps.LatLng(lat,long);
var marker = new google.maps.Marker({
position: myLatlng,
animation: google.maps.Animation.DROP,
map: map,
visible: false
})
var boxText = document.createElement("div");
boxText.style.cssText = "border: 3px solid black; margin-top: 8px; background:#333; color:#FFF; font-family:Arial; font-size:12px; padding: 5px; border-radius:6px; -webkit-border-radius:6px; -moz-border-radius:6px;";
boxText.innerHTML = '<a class="fancybox fancybox.iframe" href="' + jsonstring.link + '" onclick="jQuery(\'a.fancylink\').trigger(\'click\')";>' + jsonstring.post + '</a>'
var myOptions = {
content: boxText
,disableAutoPan: false
,maxWidth: 0
,pixelOffset: new google.maps.Size(-140, 0)
,zIndex: null
,boxStyle: {
background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/examples/tipbox.gif') no-repeat",
opacity: 0.75,
width: "180px"
}
,closeBoxMargin: "10px 2px 2px 2px"
,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
,infoBoxClearance: new google.maps.Size(1, 1)
,isHidden: false
,pane: "floatPane"
,enableEventPropagation: false
};
var ib = new InfoBox(myOptions);
ib.open(map, marker);
}
socket.on('notification', function(x) { geodata(x); });
Is there any way to trigger these fancybox iframe modal windows dynamically when the links do not exist on document ready?
Hope the above makes sense.