I am having slider for a set of data with paging, the problem is that the div containing the slider is loaded from ajax request via ajax. so it's not working.
paging function:
function loadData(page){
loading_show();
confID = $("#confID").val();
verID = $("#confID").attr("v");
$.ajax
({
type: "POST",
url: "paging-offlineTemp.php",
data: {page:page, confID: confID, verID:verID},
success: function(msg)
{
loading_hide();
$("#container").html(msg);
resize_iframe();
$(".slider").each(function(){
$(this).slider({ animate: true,
value: parseInt($(this).attr("preRate")),
min: 0,
max: 5,
step: 1
});
if($(this).attr("preRate") == -1) {
$(this).slider({ disabled: true });
td = $(this).parent("td");
tr = $(td).parent("tr");
box= $(tr).find(":checkbox");
$(box).attr("checked",true);
}
});
}
});
}
pageing-offlineTemp.php is too long but it just select the next set of data by limit
function which control slider:
$(".slider").each(function(){
$(this).slider({ animate: true,
value: parseInt($(this).attr("preRate")),
min: 0,
max: 5,
step: 1,
change: function( event, ui ) {
$(this).attr("rate", ui.value);
rate = $(this).attr("rate");
confID = $(this).attr("confID");
critID = $(this).attr("criteria");
paperID = $(this).attr("paperID");
label = $(this).parent("td").find("label");
$(label).html("New rate: "+ rate);
td = $(this).parent("td");
tr = $(td).parent("tr");
span = $(tr).find("span");
$(span).fadeIn("slow");
$.ajax ({
data:{rate:rate, confID:confID, critID:critID, paperID:paperID},
type: 'POST',
url: 'update_rate.php',
success: function(response) {
//alert(response)
$(span).delay(500).fadeOut('slow');
}
});
}
});
slider div:
<div type="" paperID="'. $paper .'" preRate="'. intval($irate) .'"
criteria="'.$row['rate_id'].'" confID="'.$conf_id.'" rate="" class="slider">
</div>
I guess is that the slider function don't fire because initially the paging container div is empty and no element with class slider, So is there a work around to keep the paging while the slider event fire?