Skip to content

Releases: nikolalsvk/render_async

render_async can emit event after it's finished

14 Oct 13:43
Compare
Choose a tag to compare

You can now pass in event_name to render_async.

<%= render_async users_path, :event_name => "users-loaded" %>

render_async will then emit event with that name after it's finished with fetching your content and appending your content to HTML.

Then you can easily execute JS code after render_async is completed with:

document.addEventListener("users-loaded", function() {
  console.log("Users have loaded!")
});

render_async drops jQuery dependency

14 Oct 12:33
Compare
Choose a tag to compare

render_async is now using vanilla JS to fetch your partials. You can now use it in projects that don't have jQuery.

Check it out on rubygems

Pass in a block to render_async

21 Sep 12:08
Compare
Choose a tag to compare

You can now pass in a block that will act as a placeholder.

If you want to add some feedback before your AJAX request is finished, passing a block is the way.

Example:

<%= render_async movie_path do %>
  <div class="cool-spinner"></div>
<% end %>

Now you will have the spinner (or anything you like) show before AJAX call finishes.

BREAKING_CHANGE:

This is a breaking change for those who relied on the <div> elements that we're rendered before
AJAX call.

Mentioned div element:

<div class="sk-spinner sk-spinner-double-bounce">
  <div class="sk-double-bounce1"></div>
  <div class="sk-double-bounce2"></div>
</div>

Those elements were there for spinner purposes but are removed from this version.

render_async inside tables

07 Sep 13:08
Compare
Choose a tag to compare

You can now put render_async inside tables!

Example:

<table>
  <tbody>
     <div>
        <tr>
          <%= render_async ... %>
        </tr>
    </div>
  </tbody>
</table> 

Support for caching

04 Sep 10:30
Compare
Choose a tag to compare

render_async now support caching. You can cache response from the AJAX call by using
render_async_cache instead of render_async helper.

In your views:

# app/views/comments/show.html.erb

# note 'render_async_cache' instead of standard 'render_async'
<%= render_async_cache comment_stats_path %>
# app/views/comments/_comment_stats.html.erb

<% cache render_async_cache_key(request.path), :skip_digest => true do %>
  <div class="col-md-6">
    <%= @stats %>
  </div>
<% end %>

Added html_options

11 Jul 07:27
Compare
Choose a tag to compare

render_async takes two arguments, path and html_options.

  • path is the ajax-capable controller action you're looking to call via get. e.g. comments_stats_path, posts_path, etc.
  • html_options is an optional hash that gets passed to a rails javascript_tag, to drop html tags into the script element.

Example utilizing html_options with a nonce:

<%= render_async users_path, nonce: 'lWaaV6eYicpt+oyOfcShYINsz0b70iR+Q1mohZqNaag=' %>

Removed obsolete files

28 Jun 08:59
Compare
Choose a tag to compare

Removed obsolete files and a git submodule from the gem