gpt4 book ai didi

jquery - 仅在首次加载 jqgrid 时运行方法

转载 作者:行者123 更新时间:2023-12-01 08:17:47 26 4
gpt4 key购买 nike

当我加载 jqgrid 时,我在 loadcomplete 部分中按以下方式填充过滤器工具栏选择框:

$(".ui-search-toolbar").find("select").each(function (index, value) {
getDropdowndata($(this).attr('NAME'));
});

问题是每次重新加载网格时都会运行此代码。例如,当我单击多个页面时,这会导致选择框填充多个值。

我想要的是仅在第一次加载网格时运行此代码。

最佳答案

最简单的解决方案是使用 bool 变量并检查填充是否已经完成

var isPopulated = false;

...

function onLoadComplete(){
if(!isPopulated){
//your code here
isPopulated = true;
}
}

关于jquery - 仅在首次加载 jqgrid 时运行方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9409082/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com