如何创建与 Ruby/Sinatra 交互的 jquery 加载器?

发布于 2024-12-20 20:49:23 字数 498 浏览 2 评论 0原文

我有一个简单的网站抓取工具,正在练习用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云淡月浅 2024-12-27 20:49:23

看看 Sinatra 的前后过滤器

Take a look into Sinatra's before and after filters

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文