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