diff options
Diffstat (limited to '')
-rw-r--r-- | src/web/_views/modal/new_post.php (renamed from web/_views/modal/new_post.php) | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/web/_views/modal/new_post.php b/src/web/_views/modal/new_post.php index 71028ad..50b9b84 100644 --- a/web/_views/modal/new_post.php +++ b/src/web/_views/modal/new_post.php @@ -22,7 +22,7 @@ <div class="modal-footer"> <?=ilang('action_submit', id: 'new-post-submit', - class: 'btn-action', + class: 'btn btn-wide btn-submit', attrs: array('type' => 'submit'), button: TRUE )?> @@ -32,14 +32,28 @@ $('#new-post-form').submit(function(e) { e.preventDefault(); let content = $('#new-post-content').val(); + let me = $(this); + + const getPost = function(data) { + if (data) { + $('#post-container').prepend(data); + } + me.closest('.modal-container').remove(); + } + + const onPost = function(data) { + let id = data[0].id; + $.get({ + url: '/_util/post/post?id=' + id, + success: getPost + }); + } $.ajax({ url: '/api/post', method: 'POST', data: JSON.stringify({ content }), - success: function(data) { - window.location.reload(); - }, + success: onPost }); }); </script> |