带有 Prototype 和不显眼的 JS 的 Ajax 加载屏幕
我正在寻找一种在 ajax 加载数据时添加加载屏幕(或框架)的解决方案。我可以在网上找到的所有其他帖子都是关于 jQuery 而不是 Prototype...我发誓我将在我的下一个项目中使用 jQuery。但无论如何,代码是这样的,使用不显眼的JS:
在search.js.erb中:
$("main_content").update("<%= escape_javascript(render(:partial => "items")) %>");
肯定有一个search.html.erb具有非常相似的内容:
<%= render :partial => "items" %>
要添加加载屏幕,我需要在这个更新功能之前添加一些东西吗? ,或者在 link_to 语句中,或者其他地方?我对此完全陌生,所以请不要介意愚蠢的问题。非常感谢。
更新:我在旧的 link_to_remote 函数中发现了一些有用的东西,它有一个 :loading 和 :loaded 标签来加载图像或屏幕出现。但是Rails 3最新的link_to中完全没有提到这一点。有没有办法将其写入js文件中?
I am looking for a solution of adding a loading screen (or frame) while ajax is loading the data. All the other posts I can find online is about jQuery rather than Prototype... I would swear that I will use jQuery for my next project. But anyway the code is like this, using unobtrusive JS:
in search.js.erb:
$("main_content").update("<%= escape_javascript(render(:partial => "items")) %>");
for sure there is a search.html.erb with pretty similar content:
<%= render :partial => "items" %>
to add a loading screen, do I need to add something before this update function, or in the link_to statement, or somewhere else? I am totally new to this so please don't mind stupid questions. Thanks very much.
Update: I found something useful in the old link_to_remote function, which has a :loading and a :loaded tag to make the loading image or screen show up. However this has been totally not mentioned in the latest link_to of Rails 3. Is there any way to write it into the js file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论