Skip to content

Releases: nikolalsvk/render_async

Toggle render_async loading

16 Aug 22:25
Compare
Choose a tag to compare

New release (2.1.1) let's you toggle when render_async gets loaded on the page.

By passing in a toggle hash, you can trigger render_async by clicking or doing other things to HTML elements.
You can trigger render_async by doing something like this:

<a href='#' id='detail-button'>detail</a>
<%= render_async comments_path, toggle: { selector: '#detail-button', event: :click } %>

This will trigger render_async to load when the user clicks the "detail" link on the page. render_async won't load until that event is triggered.

DEPRECATION WARNING:

If you've been using html_options as a second argument when calling render_async, you will have to change it to using a html_options hash like this:

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

Retry on failure and polling

06 May 20:30
Compare
Choose a tag to compare

Two new features come with 2.1.0 version! 🌮

Retry on failure

render_async can now retry on request failure for number of times you specify

<%= render_async users_path, retry_count: 5, error_message: "Users fetch has failed" %>

Closed #46

Polling feature

You can now poll your paths and URLs by passing interval option to render_async

<%= render_async comments_path, interval: 5000 %>

This will fetch comments_path every 5 seconds. Closed #67 with this feature.

POSSIBLE BREAKING CHANGE if you use this feature

Container element is NOT being replaced like in other cases. This means that you will have to deal with render_async container element. There are ways of doing this by passing in an HTML element name and HTML element class.

Remove bundler as a dependency

04 Jan 09:15
80526f5
Compare
Choose a tag to compare

Locked bundler dependency was making problems to some users #73

This release removes bundler from gemspec file and solves the issue.

Support for Turbolink 5+

10 Dec 14:35
Compare
Choose a tag to compare

If you're using Turbolinks 5 or higher, you can resolve this by setting Turbolinks configurtion of render_async to true:

RenderAsync.configure do |config|
  config.turbolinks = true # Enable this option if you are using Turbolinks 5+
end

This way, you're not breaking Turbolinks flow of loading or reloading a page.

Also, invalid jQuery Promise method name has been replaced in this version.

Using Vanilla JS by default and added error handling

06 Oct 22:20
Compare
Choose a tag to compare

Vanilla JS

POSSIBLE BREAKING CHANGE

render_async now renders the usual, non-jQuery JavaScript code to fetch your AJAX requests and
show content on the page.

If you for some reason need jQuery part of render_async, you must configure render_async:

RenderAsync.configure do |config|
  config.jquery = true
end

Error handling

render_async 2.0.0 (finally) brings error handling to the gem.

You can pass in error_message argument to the render_async helper and have it show up
in the case of a failed AJAX request.

<%= render_async users_path,
                 error_message: '<p>Sorry, users loading went wrong :(</p>' %>

If your requests fails, users will see the "Sorry, users loading went wrong :(" message.

If that's not enough, you can pass in error_event_name which will trigger and event when
something bad happens to your request.

<%= render_asyc users_path, error_event_name: 'users-error-event' %>

Then, you can catch the event like this:

document.addEventListener('users-error-event', function() {
  // I'm on it
})

Events in IE

Event creation and dispatching should now work in IE 🎉

Pass method name, data and headers to render_async

06 Oct 11:58
8ab876f
Compare
Choose a tag to compare

You can now render non-GET requests with render_async!

e.g.

<%= render_async some_post_path,
                 method: 'POST',
                 data: { fresh: 'AF' },
                 headers: { 'Content-Type': 'text' } %>

This is supported for jQuery and Vanilla JS users!

Pass in html_element_name

25 Jan 11:20
Compare
Choose a tag to compare

Changes brought in 1.2.0 version:

Pass in html_element_name

Passing html_element_name will allow you to control which HTLM element will serve as a container (placeholder) before your request gets loaded. This will prove useful if you're using render_async inside a table.

Load request only when DOM is ready

render_async will attempt to fetch request only when document is ready.

Fix non-jQuery replacing the parent node

22 Nov 10:32
8680383
Compare
Choose a tag to compare

Fixed non-jQuery JavaScript behaviour where it would replace the parent element. #39

E.g.

<div id="parent">
  Text or elements here
  <%= render_async comment_stats_path %>
</div>

render_async now won't replace the div with the parent ID.

Fix jQuery exception when it's not defined

17 Nov 10:12
Compare
Choose a tag to compare

Fix jQuery check

Trying to evaluate jQuery when it is undefined would throw a ReferenceError to the console. Trying to retrieve it on the global window instead will result in it being undefined if not defined.

Fix to make jQuery-less async actually render the response

Prior to this commit, an async request would go out but the response would be ignored, regardless of result.

Don't html-escape the path when outputting JS

Allow render_async_cache to take a placeholder

You can now pass in the placeholder to render_async_cache like you can to render_async

Use jQuery if available

14 Oct 17:53
Compare
Choose a tag to compare

render_async will utilize jQuery if available. If not, it will fallback to vanilla JavaScript to make a request and append request response to HTML.