mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: fix vote button
This commit is contained in:
1 parent
d2e18ff3d5
commit
b00615492d
3 files changed
+13
-11
No files matched your search
@@ -83,7 +83,7 @@ $downvote-color = red
|
||||
transition: border-color .2s linear, opacity .2s linear
|
||||
opacity: 0.5
|
||||
|
||||
&>form
|
||||
&>button
|
||||
width: rem(40px)
|
||||
float: left
|
||||
position: relative
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import $ from 'jquery';
|
||||
import Notification from 'vj/components/notification';
|
||||
import Rotator from 'vj/components/rotator';
|
||||
import { AutoloadPage } from 'vj/misc/Page';
|
||||
import { request } from 'vj/utils';
|
||||
@@ -25,12 +26,15 @@ const votePage = new AutoloadPage('votePage', () => {
|
||||
const $container = $button.closest('.vote');
|
||||
const $form = $button.closest('form');
|
||||
request
|
||||
.post($form.attr('action'), $form)
|
||||
.post($form.attr('action'), {
|
||||
operation: $button.attr('value'),
|
||||
psid: $form.find('input[name="psid"]').val(),
|
||||
})
|
||||
.then((data) => {
|
||||
setVoteState($container, data.vote, data.user_vote);
|
||||
})
|
||||
.catch(() => {
|
||||
// TODO(iceboy): notify failure
|
||||
.catch((e) => {
|
||||
Notification.error(`Failed to vote: ${ e.message}`);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user