Created
June 29, 2012 17:01
-
-
Save jandudulski/3019231 to your computer and use it in GitHub Desktop.
Reinvet the wheel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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