示例:我通过找到商店列表输入了邮政编码,当我选择第 10 条记录并提交表单时。如果我再次返回该表单,它应该使用滚动条位置获取详细信息。
澄清:一切都完成了,但我无法控制滚动条
$("#search").click(function(){
var zipCode = $("#zipcodeSearch").val();
if(zipCode.length){
$.ajax({
beforeSend: function(){
$(".stores").html("Loading...");
}
, type: "post"
, cache: false
, url: '/localstores/?ajax=1&view=radioView'
, data: 'zipCode=' + zipCode
, success: function(response){
$(".stores").html(response).removeClass("error");
//Checking previously selected store
if(typeof(selectedStore_ID) != 'undefined' && selectedStore_ID != 0){
$("#" + selectedStore_ID).click();
$("#" + selectedStore_ID).offset();
}else{
//Select the first local store by default
$("[name=localStore]").eq(0).click();
}
}
, error: function(error){
console.log(error);
}
, complete: function(){
if($(".stores").html() == "loading..."){
$(".stores").empty();
}
}
})
}else{
$(".stores").addClass("error").empty().html("Please enter a postcode first.");
}
});
//On click of radio items, showing the item as selected
$(".stores").delegate("[name=localStore]","click", function(){
var id = $(this).attr("id");
$("#selectedStore").html($(this).parent("td").next("td").children("label").html());
$("#selectedStoreId").val(id);
});
});
谢谢,纳雷什