Skip to content

Instantly share code, notes, and snippets.

@Mizpah
Created February 25, 2013 18:34
Show Gist options
  • Save Mizpah/5032106 to your computer and use it in GitHub Desktop.
Save Mizpah/5032106 to your computer and use it in GitHub Desktop.
Here what I started with (application.js / index.js.erb), and the subsequent attempts. I also tried an entirely new game_classes_coffee.js. note the railscast version of the file (application.js) reads: ).live("click", -- have changed this to on mylsef.
$(function() {
$("#game_classes th a, #game_classes .pagination a").on("click", function() {
$.getScript(this.href);
return false;
});
$("#game_classes_search input").keyup(function() {
$.get($("#game_classes_search").attr("action"), $("#game_classes_search").serialize(), null, "script");
return false;
});
});
$(function() {
$(document).on('click tap', '#game_classes th a, #game_classes .pagination a', () ->
$.getScript(this.href);
return false;
});
$("#products_search input").keyup(function() {
$.get($("#game_classes_search").attr("action"), $("#game_classes_search").serialize(), null, "script");
return false;
});
});
jQuery ->
# Ajax sorting and pagination on click - taken from a railscase comment and adapted.
$('#game_classes td.sortable a, #game_classes .pagination a').live('click', ->
$.getScript(this.href)
false
)
# Ajax search on submit
$('#game_classes_search').submit( ->
$.get(this.action, $(this).serialize(), null, 'script')
false
)
# Ajax search on keyup
$('#game_classes_search input').keyup( ->
$.get($("#game_classes_search").attr("action"), $("#game_classes_search").serialize(), null, 'script')
false
)
$("#game_classes").html("<%= escape_javascript(render("game_class")) %>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment