|
|
|
@ -17,18 +17,13 @@ $(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'); |
|
|
|
|
$('#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), |
|
|
|
@ -37,6 +32,7 @@ $(document).ready(function() {
|
|
|
|
|
location.reload(); |
|
|
|
|
}); |
|
|
|
|
}); // form submit
|
|
|
|
|
}); // on form load
|
|
|
|
|
}); // #cadd click
|
|
|
|
|
}); // #comments
|
|
|
|
|
}); |
|
|
|
|
}); // document ready
|
|
|
|
|