+sub action_ajax_delete {
+ my ($self) = @_;
+
+ my $js = SL::ClientJS->new;
+
+ my $current_where = $self->output_position_from_id($::form->{current_content_id}, $::form->{current_content_type}) // -1;
+ if ($self->text_block->output_position == $current_where) {
+ $js->remove('#edit_text_block_' . $self->text_block->id . '_form')
+ ->remove('#text-block-' . $self->text_block->id);
+
+ $js->show('#text-block-list-empty') if 1 == scalar @{ $self->text_block->get_full_list };
+ }
+
+ $self->text_block->delete;
+
+ $js->jstree->delete_node('#tree', '#tb-' . $self->text_block->id)
+ ->render($self);
+}