Please excuse me for asking a question that is specific to a particular plug-in, jqModal.
My webpage loads a bunch of links, all of which are tied to a jqModal object when clicked. This part works fine. I can then use a link on the page to change these links with Ajax, so the page does not reload. At this point, these newly loaded-by-ajax links should all be tied to a jqModal object when clicked, just like the initial links. But they aren't. I thought I had set it up correctly, with the Ajax callback function re-defining the jqModal ties, but it doesn’t work as I thought it should.
Code explanation: I initially call drawMap() using home coordinates of 71, 71, 71. When #compass_up is clicked, I adjust the coordinates as needed and call drawMap again. Inside drawMap I do an Ajax “load”, and inside the callback of that load I define the jqModal object.
On the initial page load, this works— after compass_up has been clicked, jqModal objects don’t stick around. I can’t figure out why!
PHP Code:
$(function() {
$("#compass_up").("click", function(){
aCoord = aCoord + 1;
bCoord = bCoord - 1;
cCoord = cCoord - 2;
drawMap(aCoord, bCoord, cCoord);
});
var aCoord = 71;
var bCoord = 71;
var cCoord = 71;
drawMap(aCoord, bCoord, cCoord);
});
//Note that @name is an attribute on the trigger element
//that has a value of “tractinfo.php?id=12345”.
function drawMap(aCoord, bCoord, cCoord) {
$("#mapdiv").load("drawmap.php?a=" + aCoord + "&b=" + bCoord + "&c=" + cCoord, function(){
//after map is loaded, initialize jqModal functionality
$('#dialog').jqm({
ajax: '@name',
ajaxText: '<p><img src="img/busy.gif" alt="loading" width="50px" height="50px" /></p>',
trigger: '.areatrigger',
});
});
}