comparison media/js/gcalendar_edit.js @ 150:b43e1288ff80

Fix #33; use $.ajax instead of $.post so we can handle errors. Also, for some reason comparing objects in a template doesn't work now. Have to compare id fields.
author Brian Neal <bgneal@gmail.com>
date Thu, 17 Dec 2009 04:14:16 +0000
parents dbd703f7d63a
children
comparison
equal deleted inserted replaced
149:ab7830b067b3 150:b43e1288ff80
1 $(document).ready(function() { 1 $(document).ready(function() {
2 $('.gcal-del').click(function () { 2 $('.gcal-del').click(function () {
3 if (confirm('Really delete this event?')) { 3 if (confirm('Really delete this event?')) {
4 var id = this.id; 4 var id = this.id;
5 if (id.match(/gcal-(\d+)/)) { 5 if (id.match(/gcal-(\d+)/)) {
6 $.post('/calendar/delete/', { id : RegExp.$1 }, function (id) { 6 $.ajax({
7 var id = '#gcal-' + id; 7 url: '/calendar/delete/',
8 $(id).parents('li').hide('normal'); 8 type: 'POST',
9 }, 'text'); 9 data: { id : RegExp.$1 },
10 dataType: 'text',
11 success: function (id) {
12 var id = '#gcal-' + id;
13 $(id).parents('li').hide('normal');
14 },
15 error: function (xhr, textStatus, ex) {
16 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' +
17 xhr.responseText);
18 }
19 });
10 } 20 }
11 } 21 }
12 return false; 22 return false;
13 }); 23 });
14 }); 24 });