tablewheel fixed()

The main idea: setcookie when the data is loaded, the height of the scroll wheel becomes 0 after the data disappears, and the cookie is not stored, and when the data appears again, getCookie obtains the value stored in the setcookie

method one:

When the data exists, if(self.isReload == false) {} wraps the data, and only accesses the cookie when it is false. When the data is not loaded after the refresh, let (self.isReload == true), and the cookie cannot be stored. When the data appears again, force self.isReload == true to become

(self.isReload == false;



(function (namespace) {
var UserModel = function (thisself) {//Please modify
var self = this in this method body;
//If thisself is specified, use thisself instead of self
if (thisself) self = thisself;
// Initialization base class common method
new KECore.Core.Nurse.CommonBase(self);
//Load patient-related classes
new KECore.Core.Nurse.PatientAboutBase(self);
new KECore.Core.Nurse.PatientListModelBase(self);
new KECore. Core.Nurse.AnnounceOfMessageModelBase(self);
self.isReload = false;

self.PageLoad = function () {
self.GetMenuByUserID();//Get the navigation menu
self.PageInit();
};

//Startup method, which must be implemented method
self.PageInit = function () {
setCookie("PatientIndex=0");
self.TITLE("Other settings");
self.deptinfo(GetQueryString("DEPT_CODE"));
// Call once to request all data
self.LoadCurrentData();
self.RefreshTime();
// Request once in 30 seconds
setInterval(self .RefreshTime, 30000);

// request once a minute
setInterval(self.LoadCurrentData, 60000);
//not autoload
console.log('1')
};

self.LoadCurrentData = function () {
self.GetAnnounceOrderProjects();
self.GetAnnounceOrderByPatsList();
self.GetV_HIS_DEPT_Info();
self.isReload = true;

console.log('2')
};


// setTimeout(function(){ },5000);
$('.table_tbody_box').scroll(function(){
var scroll_top =$('.table_tbody_box').scrollTop();

console.log(scroll_top);

//存储数据
if(self.isReload == false) {
// console.log($('.table_tbody_box').scrollTop());
//$("#table-title").scrollLeft(getCookie("scroll_left"));
setCookie("scroll_top=" + scroll_top);
}


});
$('#table-title').scroll(function(){
var scroll_left = $('#table-title').scrollLeft();
// console.log($('#table-title').scrollLeft());

//存储数据
if(self.isReload == false) {
// console.log($('.table_tbody_box').scrollTop());
//$("#table-title").scrollLeft(getCookie("scroll_left"));
setCookie("scroll_left=" + scroll_left);
}
});



self.orderlist = ko.observableArray();
self.GetAnnounceOrderByPatsList = function () {
var objdata = { deptid: self.deptinfo() };
self.orderlist.removeAll();
KEAPIHelper.GetMeaasge(new ActionUrl.QualityCheck().GetAnnounceOrderByPatsList, objdata, function (data) {
//Success
self.isReload = false;
self.orderlist.removeAll();
if (data.Data) {

var left = getCookie("scroll_left");
var top = getCookie("scroll_top");


self.orderlist(data.Data);

$(".table_tbody_box").scrollTop(top);
console.log(left,top );
//$("#table-title").scrollLeft(left);
// $(".table_tbody_box").scrollTop(getCookie("scroll_top"));
// alert('-----------'+ getCookie("scroll_left")+getCookie("scroll_top")+left+top);

}
}, function (e) {
//error
self.orderlist.removeAll();

}, false);
}

方法2,3是否绑定滚轮实现bind/unbind或者on/off代替
//1. When the data is loaded, bind the scroll, add the scroll wheel, and save it to the cookie at the same time. It can be used when the scroll wheel reappears after the receipt disappears.
//2. When the data is not loaded, the height is mostly 0. At this time, unbind the event scroll and make the scroll wheel disappear.
//3. After the automatic refresh, when the data is loaded again, add the scroll wheel, get the scroll height and width in the cookie at the same time, and pass the value in
self.LoadCurrentData = function () { 
self.GetAnnounceOrderProjects();
self.GetAnnounceOrderByPatsList();
self.GetV_HIS_DEPT_Info();
// self.isReload = true;


//2. When the data is not loaded, the height is 0, in this When unbinding the event scroll, let the scroll wheel disappear
$(".table_tbody_box").off("scroll",function(){
var scroll_top =$('.table_tbody_box').scrollTop();

console.log(scroll_top);

});
//This method is not entered because the table has width
$('#table-title').off("scroll",function(){
var scroll_left = $('#table-title').scrollLeft();

console.log(scroll_left);

});

console.log('2')
};

//1. When the data is loaded, let the scroll bind, add the scroll wheel, and save it to the cookie at the same time. When the scroll wheel appears again after the receipt disappears, you can use
$(".table_tbody_box").on("scroll",function(){
var scroll_top =$('.table_tbody_box').scrollTop();

console.log(scroll_top);
setCookie("scroll_top=" + scroll_top);
});
$('#table-title').on("scroll", function(){
var scroll_left = $('#table-title').scrollLeft();

console.log(scroll_left);
setCookie("scroll_left=" + scroll_left);
});


self.orderlist = ko.observableArray() ;
self.GetAnnounceOrderByPatsList = function () {
var objdata = { deptid: self.deptinfo() };
self.orderlist.removeAll();
KEAPIHelper.GetMeaasge(new ActionUrl.QualityCheck().GetAnnounceOrderByPatsList, objdata, function (data) {
//Success
// self.isReload = false;
//3. After automatic refresh, when the data is loaded again, add the scroll wheel and get the cookie at the same time The height and width of the
scroll
in

;
getCookie("scroll_top=" + scroll_top);
});
$('#table-title').on("scroll",function(){
var scroll_left = $('#table-title').scrollLeft() ;

console.log(scroll_left);
getCookie("scroll_left=" + scroll_left);
});



self.orderlist.removeAll();
 
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325258804&siteId=291194637
Recommended