解決jeecg3.5中因爲easyui的緣由會加載兩次數據的問題

在解決完jeecgt3.5中的這個問題:jeecg3.5中實現從一個頁面跳轉到另外一個頁面 後,發現數據會被加載兩次,在網上找了半天也沒找到緣由,最後發現是因爲調用datagrid方法太快引發的,解決方法爲使用setTimeout延遲執行datagrid方法,具體以下:java

$(function() {
		//延遲200毫秒執行,不然easyui會加載兩次數據
		setTimeout(init, 200);
	});
function init() {
		//alert($('#jeecgDemoList'));
		var href = decodeURIComponent(window.location.href);
		//alert(href);
		var idx = href.indexOf('selectedParams');
		if (idx != -1) {
			idx = href.indexOf("{", idx);
			if (idx != -1) {
				var endIdx = href.indexOf("}", idx);
				if (endIdx != -1) {
					var selectedParams = href.substring(idx, endIdx + 1);
					var jsonParam = $.parseJSON(selectedParams);
					$('#jeecgDemoListtb').find('*').each(function() {
						if (jsonParam[$(this).attr('name')] != undefined) {
							if ($(this)[0].tagName == "SELECT") {
								//$(this).attr("value", "0");
								$(this).val(jsonParam[$(this).attr('name')]);
							} else if ($(this)[0].tagName == "INPUT") {
								$(this).val(jsonParam[$(this).attr('name')])
							}
							
						}
					});
				}
				
			}
			
		}
		jeecgDemoListsearch();
	}
相關文章
相關標籤/搜索