如何创建与 Ruby/Sinatra 交互的 jquery 加载器?
我有一个简单的网站抓取工具,正在练习用 Ruby + Sinatra + Nokogiri 构建它。
我有一个名为的加载程序,它半透明地覆盖整个屏幕。
截至目前,页面初始加载时的设置如下(通常在初始加载时的任何给定时间页面上都会有大量数据)
$(window).load(function() {
$('#loading').fadeOut();
$('#wrapper').fadeIn();
});
我的问题是,是否可以激活此加载器,然后'当 nokogiri 工作时,在我的 ruby 脚本中取消激活它?
例如,在...
post '/refresh' do
# scraping code here that can take seconds to minutes
end
我想在开始时启用加载程序,然后在最后禁用它。不知道我会如何去做这件事,但任何帮助将不胜感激!
I have a simple website scraper that I'm practicing on building in Ruby + Sinatra + Nokogiri.
I have a loader called that semi-transparently covers up the entire screen.
As of right now, its set to the following for when the page initially loads (usually theres a large amount of data on the page at any given time when its loaded initially)
$(window).load(function() {
$('#loading').fadeOut();
$('#wrapper').fadeIn();
});
My question is, is it possible to activate this loader and then 'unactivate' it during my ruby script while nokogiri is working?
For example, in...
post '/refresh' do
# scraping code here that can take seconds to minutes
end
I want to enable the loader at the beginning, then disable it at the end. Not sure how I would go about doing this, but any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看 Sinatra 的前后过滤器
Take a look into Sinatra's before and after filters