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
    New Coder
    Join Date
    Apr 2009
    Location
    San Diego, CA
    Posts
    64
    Thanks
    2
    Thanked 1 Time in 1 Post

    Livequery not reattaching handlers

    So using this function:
    Code:
    $j(".versions").livequery('change', function() {
    	var verid = $j(".versions option:selected");
    	var prodid = $j(this).attr('id');
    	$j.ajax({
    		method: "get",
    		url: "../includes/ajax/release.php",
    		data: "vid="+verid.val()+"&mdl="+prodid,
    		beforeSend: function() 
    			{$j('#loading').show('fast');},
    		complete:  function() 
    			{$j('#loading').hide('fast');},
    		success: function(json) {
    			$j('.rel_info').show('slow');
    			$j('.rel_info').html(json);
    		}
    	});
    });
    The script will run, i.e. the data loads via AJAX when I select the items from my drop down, but the event handlers in the subsequently called script don't reattach like they should. Am I missing something in the implementation? FireBug is giving me no errors.

    The content I pull in via AJAX gives me a list of categories, titled by links that when clicked use the toggle event to show the data for that category. This is an example of the toggle function:
    Code:
    		
    $j("#guideClick").click(function(){
    	$j('#guidenotes').toggle("fast", function() {
    		var aliveTime = $j.ajax('includes/alive.php');
    	});
    	var img_src = $j("#guideImg").attr('src');
    	if (img_src == img_expand) {
    		var curr_img = img_collapse;
    	} else if (img_src == img_collapse) {
    		var curr_img = img_expand;
    	}
    	$j("#guideImg").ImageSwitch({NewImage:curr_img, Speed: 1});
    	return false;
    });
    The toggle works when not being called by AJAX, so I know that piece of code is sound. Thanks in advance!

  • #2
    New Coder
    Join Date
    Apr 2009
    Location
    San Diego, CA
    Posts
    64
    Thanks
    2
    Thanked 1 Time in 1 Post
    Oh.... don't mind me! I was trying to use the livequery call on the ajax function, where it should have been used on the functions I want rebound.

    The second function should be:
    Code:
    $j("#guideClick").livequery('click', function(){
    	$j('#guidenotes').toggle("fast", function() {
    		var aliveTime = $j.ajax('includes/alive.php');
    	});
    	var img_src = $j("#guideImg").attr('src');
    	if (img_src == img_expand) {
    		var curr_img = img_collapse;
    	} else if (img_src == img_collapse) {
    		var curr_img = img_expand;
    	}
    	$j("#guideImg").ImageSwitch({NewImage:curr_img, Speed: 1});
    	return false;
    });


  •  

    Tags for this Thread

    Posting Permissions

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