diff options
| author | Freya Murphy <freya@freyacat.org> | 2024-04-01 11:09:25 -0400 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2024-04-01 11:09:25 -0400 |
| commit | 3a82baec9d793edf81ac2b151b0f4d4159641375 (patch) | |
| tree | f9d50c296b078ac48c2a2391c172c3ccf37edb3f /src/web/_views/modal/new_post.php | |
| parent | refactor asset dir, refactor oberver in lib (diff) | |
| download | xssbook2-3a82baec9d793edf81ac2b151b0f4d4159641375.tar.gz xssbook2-3a82baec9d793edf81ac2b151b0f4d4159641375.tar.bz2 xssbook2-3a82baec9d793edf81ac2b151b0f4d4159641375.zip | |
login and register, liking on homepage
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> |