Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts

    ajax callback function should be defining jqModal objects but doesn't

    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(aCoordbCoordcCoord);
        });

        var 
    aCoord 71;    
        var 
    bCoord 71;    
        var 
    cCoord 71;

        
    drawMap(aCoordbCoordcCoord);
    });

    //Note that @name is an attribute on the trigger element
    //that has a value of “tractinfo.php?id=12345”.
    function drawMap(aCoordbCoordcCoord) {
        $(
    "#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',
            }); 
        });



  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    The way I eventually got this to work is I remove the popup Div from the DOM (id=dialog in the code below) and recreate it into the DOM every time ajax reloads the links. I doubt this is the best way to be doing this but I got it to work so I'm hanging onto the solution until a better one comes along.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •