Skip to content

Instantly share code, notes, and snippets.

@l02162010
Created June 1, 2016 05:16
Show Gist options
  • Save l02162010/1647ed25ac747c40497573200ac6b521 to your computer and use it in GitHub Desktop.
Save l02162010/1647ed25ac747c40497573200ac6b521 to your computer and use it in GitHub Desktop.
<script>
$(document).ready(function () {
var actionForm = $('#actionForm');
var deleteBtn = $('.btn.delete');
var updateBtn = $('.btn.update');
deleteBtn.click(function () {
if (!confirm("are you sure?")) {
return false;
}
actionForm.attr('action', '/admin/item/delete/' + $(this).attr('data-id'));
actionForm.removeAttr('enctype');
actionForm.submit();
});
updateBtn.click(function () {
actionForm.attr('action', '/admin/item/update/' + $(this).attr('data-id'));
actionForm.attr('enctype', 'multipart/form-data');
actionForm.submit();
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment