Browse Source

+ public/theme/js/main.js : update js

master
Alex 'AdUser' Z 9 years ago
parent
commit
c39d31f598
  1. 14
      public/theme/js/main.js

14
public/theme/js/main.js

@ -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

Loading…
Cancel
Save