(function(){ spud.admin.posts = { edit: function(){ $('body').on('click', '.spud-post-add-category', clickedPostAddCategory); $('body').on('submit', '.spud-post-category-form', submittedPostCategoryForm); } }; var clickedPostAddCategory = function(e){ e.preventDefault(); $.ajax({ url: $(this).attr('href'), dataType: 'html', success: function(html, textStatus, jqXHR){ spud.admin.modal.displayWithOptions({ title: 'Add Category', html: html }); } }); }; var submittedPostCategoryForm = function(e){ e.preventDefault(); var form = $('.spud-post-category-form'); $.ajax({ url: form.attr('action'), data: form.serialize(), type: 'post', dataType: 'json', success: savedPostCategorySuccess, error: savePostCategoryError }); }; var savedPostCategorySuccess = function(data, textStatus, jqXHR){ var checkbox = ''; checkbox += '