kevinjardine / shoutout

Allows adding content (possibly with file attachments) directly to the river
5 stars 3 forks source link

Behavior when a Polls vote is submitted #12

Closed mrclay closed 12 years ago

mrclay commented 12 years ago

Replace the [Vote] button with "Thank you for voting!", leave the selected OPTION selected and set the disabled attribute on the others.

kevinjardine commented 12 years ago

I'm not sure what the requirement is here. Currently when a person has voted on a poll, it displays the results. This is standard behaviour for the poll widgets I've seen. Are you asking for some other behaviour?

mrclay commented 12 years ago

Switching to the results would be fine, but still show a Thank You message and remove the [Show poll] toggle.

kevinjardine commented 12 years ago

That's what the code currently does for me using FF at least. A thank you message and no link. Are you seeing a show poll link even after a vote?

mrclay commented 12 years ago

In FF9/OSX on your socnet site, voting simply unselects the selected option.

kevinjardine commented 12 years ago

Wowsa. I can't reproduce that in FF, IE or Chrome under Win 7. The relevant JS is just this little snippet:

$('#poll-vote-button').live('click',function(e) { e.preventDefault();
elgg.action('action/polls/vote', {data: $('#poll-vote-form').serialize(), success : function(response) { $('#poll-container').html(response.result); } }); });

As I don't have a Mac, I'll need a bit more information. If you vote on the poll view page, do you see the same non-behaviour that you see in the shoutout? Does your browser report any JS errors?

kevinjardine commented 12 years ago

Also, could you try it in another browser, eg. Safari, to see if you see the same behaviour?

kevinjardine commented 12 years ago

Is it possible that you were trying to vote when logged out? That was a bug I just fixed. Public polls are only public in the sense that non-logged-in-users can see the results. They now get a message inviting them to login rather than a vote button.

mrclay commented 12 years ago

$.html() is getting called but is just silently failing. You might try removing the leading comment from the returned HTML snippet. If so, I'll report this as a jQuery bug :/

mrclay commented 12 years ago

To be clearer, $('#poll-container').html(response.result); is being called, but I think the leading HTML comment in response.result is breaking jQuery.

mrclay commented 12 years ago

In any case, the Vote button should be disabled immediately on clicking so multiple requests aren't sent.

(sorry for closing the issue, misclicked!)

kevinjardine commented 12 years ago

OK, I have removed the comment and disabled the button after it is clicked. Please tell me if that fixes things for you.

mrclay commented 12 years ago

Works for me (only for new polls, but that's fine).

kevinjardine commented 12 years ago

It turned out that there was a bug when determining whether a person had already voted on a poll, which was really at the heart of the problem. I was passing an owner_guid option when doing the check (which worked for the creator of the poll), but it should have been annotation_owner_guid instead.