Sha256: d67869f134d0dbf5eff4a5f8b5ede70bd7a50fdab4283265f05d99eb6606044e
Contents?: true
Size: 1.04 KB
Versions: 12
Compression:
Stored size: 1.04 KB
Contents
$(function(){ /* pretty much yoinked exactly from jQuery site */ $("#add-form").submit(function(event) { /* stop form from submitting normally */ event.preventDefault(); // my best take so far at scraping form data var formData = {}; $.each($(this).serializeArray(), function(i, field) { formData[field.name] = field.value; }); /* Send the data using post and put the results in a div */ $.post( this.action + '.json', formData, function( data ) { $( "#main" ).append( data.html ); } ); }); $('.delete-button').click(function(event){ event.preventDefault(); var btn = $(this); $.get(this.href + '.json', function(data){ if (data.success === true) { // fadeOut on a tr doesn't work, but on td it does. btn.parent().parent('tr').find('td').fadeOut(); // we don't explicitly need to do this, because next time the page // loads it won't be there. plus, it breaks our fadeout //btn.parent().parent('tr').remove(); } }); }); });
Version data entries
12 entries across 12 versions & 1 rubygems