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