annotate media/js/forums.js @ 92:62eb9cbbcffc
Need an import for the InvalidPage exception from django.core.paginator.
author |
Brian Neal <bgneal@gmail.com> |
date |
Sun, 13 Sep 2009 04:09:08 +0000 |
parents |
021492db4aad |
children |
23035afdeae8 |
rev |
line source |
bgneal@89
|
1 $(document).ready(function() {
|
bgneal@89
|
2 var postText = $('#id_body');
|
bgneal@89
|
3 var postButton = $('#forums-reply-post');
|
bgneal@89
|
4 postButton.click(function () {
|
bgneal@89
|
5 var text = $.trim(postText.val());
|
bgneal@89
|
6 if (text.length == 0) {
|
bgneal@89
|
7 alert('Please enter some reply text.');
|
bgneal@89
|
8 return false;
|
bgneal@89
|
9 }
|
bgneal@89
|
10 $(this).attr('disabled', 'disabled').val('Posting reply...');
|
bgneal@89
|
11 $.ajax({
|
bgneal@89
|
12 url: '/forums/quick-reply/',
|
bgneal@89
|
13 type: 'POST',
|
bgneal@89
|
14 data: {
|
bgneal@89
|
15 body : postText.val(),
|
bgneal@89
|
16 topic_id : $('#id_topic_id').val()
|
bgneal@89
|
17 },
|
bgneal@89
|
18 dataType: 'html',
|
bgneal@89
|
19 success: function (data, textStatus) {
|
bgneal@89
|
20 postText.val('');
|
bgneal@89
|
21 $('#forum-topic tr:last').after(data);
|
bgneal@89
|
22 var lastTr = $('#forum-topic tr:last');
|
bgneal@89
|
23 lastTr.hide();
|
bgneal@89
|
24 lastTr.fadeIn(3000);
|
bgneal@89
|
25 postButton.removeAttr('disabled').val('Submit Reply');
|
bgneal@89
|
26 },
|
bgneal@89
|
27 error: function (xhr, textStatus, ex) {
|
bgneal@89
|
28 alert('Oops, an error occurred. Please reload the page and try again.');
|
bgneal@89
|
29 postButton.removeAttr('disabled').val('Submit Reply');
|
bgneal@89
|
30 }
|
bgneal@89
|
31 });
|
bgneal@89
|
32 return false;
|
bgneal@89
|
33 });
|
bgneal@89
|
34 });
|