Advertisement
kocuogebz

custom.js

Jun 4th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. this.delete_blog_post = function() {
  2.            
  3.     var _this = $(this);
  4.            
  5.     $('body').on('click', '.delete', function(e){
  6.                
  7.         e.preventDefault();
  8.                
  9.         var confirmation = confirm('Are you sure you want to delete this item?');          
  10.         var target = '.notify';
  11.                
  12.         if (confirmation) {
  13.                    
  14.             $(this).parents(".odd").animate({ backgroundColor: "#fbc7c7" }, "fast").animate({ opacity: "hide" }, "slow");
  15.             scroll_top( $(target) );
  16.                    
  17.             var data = {
  18.                 post_id: $(this).attr('id'),
  19.                 //csrf_token: $('input[name="csrf_token"]').val()
  20.             }
  21.                    
  22.             $.post( base_url + 'admin/posts/delete_post', data, function( response ) {
  23.                        
  24.                 if(response === 'success'){
  25.                            
  26.                     $(target).html('<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-check"></i> Successfully updated!</h4></div>');
  27.                     _this.load_blog_posts(1);
  28.                            
  29.                 } else {
  30.                            
  31.                     $(target).html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><p><i class="icon fa fa-ban"></i> ' + response + ' </p></div>');
  32.                            
  33.                 }
  34.                        
  35.             });
  36.         }
  37.                
  38.     });
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement