Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我的 Rails 应用程序的一页上动态更新一些列表。我知道不显眼的 javascript 以及如何通过链接和表单调用它。但是,有没有什么漂亮的方法可以通过计时器调用不引人注目的 javascript。
你可以有类似的东西
<ul data-behaviour='list-updater'> ... </ul>
并在 javascript 资产文件中
$.fn.updaterComponent = function() { var timer= function () { ... }; setInterval(timer, 1000); } $( function() { $("[data-behaviour='list-updater']").updaterComponent(); });
这将是相当不显眼的:)