Skip to content

Instantly share code, notes, and snippets.

@DCarper
Created February 7, 2011 20:59
Show Gist options
  • Save DCarper/815199 to your computer and use it in GitHub Desktop.
Save DCarper/815199 to your computer and use it in GitHub Desktop.
- form_for [@bracket, @bracket.guess_for(user)], :html => {:method => :delete, :class => 'destroy_guess'} do |f|
= f.submit "Delete Guess"
$(function() {
$(".destroy_guess").destroyGuesses()
})
$.fn.destroyGuesses = function() {
$(this).submit( function() {
$container = $(this).parent();
$.ajax({ url: this.action + '.json',
data: $(this).serialize(),
type: 'post',
success: function(data, textStatus, XMLHttpRequest){
$("#flash").text(data.notice);
$container.html(disabled_button)
}})
return false;
})
return $(this);
}
<form method="post" id="edit_guess_47" class="destroy_guess" action="/insider/brackets/2/guesses/47">
<div style="margin: 0pt; padding: 0pt; display: inline;">
<input type="hidden" value="delete" name="_method" disabled="">
<input type="hidden" value="Rr68PIJ8eZ7/U7gWy6XPM1fK5m9mWlCLu9yB39C38Z8=" name="authenticity_token" disabled="">
</div>
<input type="submit" value="Delete Guess" name="commit" id="guess_submit">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment