|
|
|
@ -17,26 +17,22 @@ $(document).ready(function() {
|
|
|
|
|
// handle 'add comment' button click
|
|
|
|
|
$('a#cadd').click(function(e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
var url = document.createElement('a'); |
|
|
|
|
url.href = window.location; |
|
|
|
|
$(this).remove(); |
|
|
|
|
var form = $('<form method="POST" action="/comments/add" id="cadd">'); |
|
|
|
|
$(form).append('<hr />'); |
|
|
|
|
$(form).append('<textarea /><br />'); |
|
|
|
|
$(form).append('<input type="submit" value="Add">'); |
|
|
|
|
$(form).append('<input type="hidden" value="' + escape(url.pathname) + '" name="pageid">'); |
|
|
|
|
$(form).appendTo('#comments'); |
|
|
|
|
// form submit with ajax
|
|
|
|
|
$('#comments form').submit(function(e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
var text = $('#comments textarea').val(); |
|
|
|
|
$.post('/comments/add', { |
|
|
|
|
'pageid': escape(url.pathname), |
|
|
|
|
'text': text, |
|
|
|
|
}, function() { |
|
|
|
|
location.reload(); |
|
|
|
|
}); |
|
|
|
|
}); // form submit
|
|
|
|
|
$('#comments').load('/comments/new', function() { |
|
|
|
|
// form submit with ajax
|
|
|
|
|
$('#comments form').submit(function(e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
var url = document.createElement('a'); |
|
|
|
|
url.href = window.location; |
|
|
|
|
var text = $('#comments textarea').val(); |
|
|
|
|
$.post('/comments/add', { |
|
|
|
|
'pageid': escape(url.pathname), |
|
|
|
|
'text': text, |
|
|
|
|
}, function() { |
|
|
|
|
location.reload(); |
|
|
|
|
}); |
|
|
|
|
}); // form submit
|
|
|
|
|
}); // on form load
|
|
|
|
|
}); // #cadd click
|
|
|
|
|
}); // #comments
|
|
|
|
|
}); |
|
|
|
|
}); // document ready
|
|
|
|
|