-
-
Save tubbo/2997310 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| respond_to :html, :js | |
| def destroy | |
| @student = User.find(params[:id]) | |
| if @student.destroy | |
| render json: { student: @student, student_id: dom_id(@student) } | |
| else | |
| render nothing: true | |
| end | |
| end |
This file contains hidden or 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
| $(function () { | |
| $('.delete-student').on('click', function (event) { | |
| event.preventDefault(); | |
| var $link = $(this); | |
| if (confirm("You sho bout that?")) { | |
| $.ajax({ | |
| type: 'DELETE' | |
| url: $link.attr('href'), | |
| success: function (response) { | |
| console.log("Test if this is actually firing"); // Not logging to the console. | |
| $(response.student_id).hide(); // Hide the deleted record. | |
| $link.fadeOut(); | |
| } | |
| }); | |
| } | |
| }); | |
| }); |
This file contains hidden or 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
| = link_to student_path(s), :class => "btn btn-mini btn-danger delete-student", :method => "delete", :confirm => "Are you sure you want to delete this student?", :remote => "true", :title => "Delete Student" do | |
| %i.icon-remove |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lol this is from #rubyonrails IRC...how did you even find this?