...

View Full Version : jQuery Livequery not reattaching handlers



Gremlyn1
12-17-2009, 01:15 AM
So using this function:


$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:


$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!

Gremlyn1
12-17-2009, 06:15 PM
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:

$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;
});



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum