Browse Source

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

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

36
public/theme/js/main.js

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

Loading…
Cancel
Save