提交 be71e1e6 编写于 作者: Z zTree-github

fixed issue: fuzzySearch.js & Demo Thanks @SadWood & @JerryWang24

上级 9523be07
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
fuzzySearch ( zTreeId, searchField, isHighLight, isExpand ) fuzzySearch ( zTreeId, searchField, isHighLight, isExpand )
</li> </li>
<li><p>搜索试试看:<br/> <li><p>搜索试试看:<br/>
关键字:<input type="text" id="key" value="" class="empty" /><br/> 关键字:<input type="text" id="key" value="" class="empty" placeholder="请输入关键字"/><br/>
</p> </p>
</li> </li>
</ul> </ul>
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
fuzzySearch ( zTreeId, searchField, isHighLight, isExpand ) fuzzySearch ( zTreeId, searchField, isHighLight, isExpand )
</li> </li>
<li><p>Try to search:<br/> <li><p>Try to search:<br/>
Keywords:<input type="text" id="key" value="" class="empty" /><br/> Keywords:<input type="text" id="key" value="" class="empty" placeholder="Please Input Keyword"/><br/>
</p> </p>
</li> </li>
</ul> </ul>
......
...@@ -110,6 +110,7 @@ ...@@ -110,6 +110,7 @@
}); });
var timeoutId = null; var timeoutId = null;
var lastKeyword = '';
// excute lazy load once after input change, the last pending task will be cancled // excute lazy load once after input change, the last pending task will be cancled
function searchNodeLazy(_keywords) { function searchNodeLazy(_keywords) {
if (timeoutId) { if (timeoutId) {
...@@ -117,8 +118,12 @@ ...@@ -117,8 +118,12 @@
clearTimeout(timeoutId); clearTimeout(timeoutId);
} }
timeoutId = setTimeout(function() { timeoutId = setTimeout(function() {
if (lastKeyword === _keywords) {
return;
}
ztreeFilter(zTreeObj,_keywords); //lazy load ztreeFilter function ztreeFilter(zTreeObj,_keywords); //lazy load ztreeFilter function
$(searchField).focus();//focus input field again after filtering // $(searchField).focus();//focus input field again after filtering
lastKeyword = _keywords;
}, 500); }, 500);
} }
} }
\ No newline at end of file
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
</font> </font>
*2018.12.10* v3.5.37
* [修改] fuzzySearch.js & Demo Thanks @SadWood & @JerryWang24
*2018.08.21* v3.5.37 *2018.08.21* v3.5.37
* [修改] 替换 scrollIntoViewIfNeeded 方法 Thanks @jocki84 * [修改] 替换 scrollIntoViewIfNeeded 方法 Thanks @jocki84
* [修改] 部分 API 文字错误 * [修改] 部分 API 文字错误
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册