Skip to content

Commit

Permalink
Add delete tab function in JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Vetter committed Oct 23, 2013
1 parent 9a92bee commit 8c812cd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions fancypages/static/fancypages/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ fancypages.editor = {
initialiseEventsOnPageContent: function () {
// Add a new tab to the selected tabbed block block
$(document).on('click', 'a[data-behaviours~=add-tab]', fancypages.eventHandlers.addNewTab);
$(document).on('click', 'a[data-behaviours~=delete-tab]', fancypages.eventHandlers.deleteTab);
//load the form to select a new block to add to the container
//and display it in a modal
$("a[data-behaviours~=load-modal]").click(fancypages.eventHandlers.loadModal);
Expand Down
24 changes: 24 additions & 0 deletions fancypages/static/fancypages/js/event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@ fancypages.eventHandlers = {
});
},

deleteTab: function (ev) {
ev.preventDefault();

$.ajax({
url: $(this).data('action'),
type: 'DELETE',
data: {
content_type: $(this).data('content-type-id'),
object_id: $(this).parents('.block').data('block-id')
},
beforeSend: function (xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", fancypages.getCsrfToken());
},
success: function (data) {
parent.fancypages.editor.reloadPage();
},
error: function () {
parent.fancypages.utils.messages.error(
"An error occured trying to add a new tab. Please try it again."
);
}
});
},

loadIframeModal: function (ev) {
var iframeId = $(this).data('iframe-id');
if (iframeId === undefined) {
Expand Down

0 comments on commit 8c812cd

Please sign in to comment.