|
|
@ -17,18 +17,13 @@ $(document).ready(function() { |
|
|
|
// handle 'add comment' button click
|
|
|
|
// handle 'add comment' button click
|
|
|
|
$('a#cadd').click(function(e) { |
|
|
|
$('a#cadd').click(function(e) { |
|
|
|
e.preventDefault(); |
|
|
|
e.preventDefault(); |
|
|
|
var url = document.createElement('a'); |
|
|
|
|
|
|
|
url.href = window.location; |
|
|
|
|
|
|
|
$(this).remove(); |
|
|
|
$(this).remove(); |
|
|
|
var form = $('<form method="POST" action="/comments/add" id="cadd">'); |
|
|
|
$('#comments').load('/comments/new', function() { |
|
|
|
$(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
|
|
|
|
// form submit with ajax
|
|
|
|
$('#comments form').submit(function(e) { |
|
|
|
$('#comments form').submit(function(e) { |
|
|
|
e.preventDefault(); |
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
var url = document.createElement('a'); |
|
|
|
|
|
|
|
url.href = window.location; |
|
|
|
var text = $('#comments textarea').val(); |
|
|
|
var text = $('#comments textarea').val(); |
|
|
|
$.post('/comments/add', { |
|
|
|
$.post('/comments/add', { |
|
|
|
'pageid': escape(url.pathname), |
|
|
|
'pageid': escape(url.pathname), |
|
|
@ -37,6 +32,7 @@ $(document).ready(function() { |
|
|
|
location.reload(); |
|
|
|
location.reload(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); // form submit
|
|
|
|
}); // form submit
|
|
|
|
|
|
|
|
}); // on form load
|
|
|
|
}); // #cadd click
|
|
|
|
}); // #cadd click
|
|
|
|
}); // #comments
|
|
|
|
}); // #comments
|
|
|
|
}); |
|
|
|
}); // document ready
|
|
|
|