Skip to content

Instantly share code, notes, and snippets.

@jandudulski
Created June 29, 2012 17:01
Show Gist options
  • Save jandudulski/3019231 to your computer and use it in GitHub Desktop.
Save jandudulski/3019231 to your computer and use it in GitHub Desktop.
Reinvet the wheel
# Instead of:
= link_to 'Fajne', fajny_path, id: 'fajny-url'
:javascript
$('#fajny-url').on('click', function() {
$.ajax('jakis/path', {
...
}).done(function(data) {
$('gdzieś').html(data);
});
});
# do
= link_to 'Fajne', fajny_path, id: 'fajny-path', remote: true
# or in newer rails
= link_to 'Fajne', fajny_path, id: 'fajny-path', data: { remote: true }
:javascript
$('#fajny-path').on('ajax:before', function() {
// show overlay czy coś, że się ładuje
}).on('ajax:success', function(event, data, status, xhr) {
$('gdzieś').html(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment