JQERY newbie ?

  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

The code below works fine in FireFox.

But, in IE7 it appears to hit the return false, before the get finishes.

Code: [ Select ]
function handleLoading(data) {
        var $content = $("<div></div>").html(data);
        var $visualBadge = $("#visualBadge");
        
        $visualBadge.children("div").replaceWith($content);
        $visualBadge.find("a").click(handleClick);
    }
    
    function handleClick(evt) {
        var link = this;        
        var path = link.href;
        if(path.indexOf("#") != (path.length-1)){
            alert(path);
            $.get(link.href, handleLoading);             
            evt.preventDefault();
            return false;    
        }
    }
  1. function handleLoading(data) {
  2.         var $content = $("<div></div>").html(data);
  3.         var $visualBadge = $("#visualBadge");
  4.         
  5.         $visualBadge.children("div").replaceWith($content);
  6.         $visualBadge.find("a").click(handleClick);
  7.     }
  8.     
  9.     function handleClick(evt) {
  10.         var link = this;        
  11.         var path = link.href;
  12.         if(path.indexOf("#") != (path.length-1)){
  13.             alert(path);
  14.             $.get(link.href, handleLoading);             
  15.             evt.preventDefault();
  16.             return false;    
  17.         }
  18.     }


Using this line of code in place of my $.get above...I can see where the return data stops.
Code: [ Select ]
$.get(link.href, function(returned_data){alert(returned_data);});


Is there anyway to ensure the $.get completes before it runs the "return false"?
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

i think the answer is setting async to false for my get function, but i'm newbie to the point I'm not quite sure how to do that...

any pointers based on what I've already provided?
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

Maybe I should explain the intent of my code here.

I'm trying to override the onClick event of all <a> tags in my div id=virtualBadge

I want to make those links load their intended href in my div id=virtualBadge not in the window.top

Hopefully a little background will shed light on a possible solution
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

Ok...I've narrowed it down...I know where the failure is coming now.

In IE7 & IE6 the first alert, pops up all of the data. The second alert pops up empty.

Code: [ Select ]
function handleLoading(data) {
   alert(data);   
   var $visualBadge = $("#visualBadge");      
   $visualBadge.html(data)
   alert($visualBadge.html());
   $visualBadge.find("a").click(handleClick);
}
  1. function handleLoading(data) {
  2.    alert(data);   
  3.    var $visualBadge = $("#visualBadge");      
  4.    $visualBadge.html(data)
  5.    alert($visualBadge.html());
  6.    $visualBadge.find("a").click(handleClick);
  7. }


In Firefox 3.5 and Chrome it works fine.

Any idea how to fix this in IE7 & IE6?

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 43 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.