Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-19-2009, 11:53 PM   PM User | #1
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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',
        }); 
    });


__________________
Fumigator is offline   Reply With Quote
Old 05-22-2009, 06:38 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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.
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:32 PM.


Advertisement
Log in to turn off these ads.