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
$('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

Loading…
Cancel
Save