JQuery QuickSearch:如果输入不为空则在加载时搜索
我已经使用了 jquery fastsearch 插件,它工作正常,除了一个问题。我希望在加载页面时运行快速搜索。我创建了第二个快速搜索函数(在加载页面时调用)并将绑定更改为其他内容,但它在“加载”或“就绪”时不起作用。
如果我将绑定更改为“焦点”并将焦点放在文本字段上,它就可以工作,但仅限于 IE。
我想这样做的原因是因为用户离开页面时有一个“查看”链接。当他们回来时,我希望搜索结果与他们离开时一样。
I have used the jquery quicksearch plugin and it works fine, except for one problem. I would like the quicksearch to run when the page is loaded. I have created a second quicksearch function (which is called when the page is loaded) and changed the bind to something else, but it won't work on "load" or "ready".
If I change the bind to "focus" and put the focus onto the textfield it works, but only in IE.
The reason I want to do this is because there is a "view" link where the user leaves the page. When they come back, I would like the search results to be as they left them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为您提供的懒惰解决方案:
lazy solution for you:
其实仔细想想,
这可能是因为 doc.ready 不是在所有 js 加载时完成的,所以当你在页面加载时调用它时,快速搜索插件还没有完成初始化。
相反,您应该在插件初始化时使用回调
actually thinking about it,
it's probably because doc.ready isnt when all js is loaded, so the quick search plugin isnt finished initialising when u call it on page load.
instead you should use a callback on the plugin initialisation
您可以使用:
更多功能:
You can use:
More functions: