diff --git a/app/views/render_async/_request_jquery.js.erb b/app/views/render_async/_request_jquery.js.erb index 5b1c582..58c8c8a 100644 --- a/app/views/render_async/_request_jquery.js.erb +++ b/app/views/render_async/_request_jquery.js.erb @@ -18,11 +18,16 @@ if (window.jQuery) { } function _runAfterDocumentLoaded(callback) { - <% if turbolinks %> - $(document).one('turbolinks:load', callback); - <% else %> - $(document).ready(callback); - <% end %> + if (document.readyState === 'complete' || document.readyState === 'interactive') { + // Handle a case where nested partials get loaded after the document loads + callback(); + } else { + <% if turbolinks %> + $(document).one('turbolinks:load', callback); + <% else %> + $(document).ready(callback); + <% end %> + } } function _makeRequest(currentRetryCount) {