My task was to put confirmation dialog when clicking vote button to confirm user voting. I am using eventBeforeRate to handle this. But when user decide to not confirm his vote, I cannot prevent from making vote request. There is no chance to modify data variable in eventBeforeRate to prevent voting being processed.
I had to hack Rate javascript code, which I am not really happy with this. In eventBeforeRate I added user response decision to data variable like this:
data.voting_confirmed = false
And then I had to hack the code of Drupal.rateVote function in rate.js to not process request when voting is not confirmed.
Can this be please implemented in rate.js by default? Initialize variable like data.voting_approved = true, but if eventBeforeRate change it to false, do not process request. Now I have to take care of every Rate module update :(
Or is there other simple way to do it? I can imagine of unbinding click events or something like that, which seems more frustrating to do.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | cannot_prevent_voting-1871002-6.patch | 2.9 KB | subhojit777 |
| #5 | cannot_prevent_voting-1871002-5.patch | 2.79 KB | subhojit777 |
Comments
Comment #1
hideaway commentedComment #1.0
hideaway commentedtypo
Comment #1.1
hideaway commentedtypo
Comment #2
hideaway commentedTo be more precise, I would like to have rate.js look something like this:
Part I have modified is market with "!!!" in the code above
Comment #2.0
hideaway commentedtypo
Comment #3
Doronro commentedHi, just wondering if you found a good solution for this?
I posted a related question and quoted this post there...
https://www.drupal.org/node/2319269
Comment #4
subhojit777I also agree with @hideaway in #2. Seems like we have to handle further execution by altering the
data, and then continuing the execution from the JavaScript that stopped further execution.Comment #5
subhojit777This patch checks for
isPreventedand then continues the execution.Comment #6
subhojit777I checked that in order to save rate to database using
rate_save_vote($widget, $content_type, $content_id, $value, $ahah = FALSE, $reset = FALSE), we need the unique token. You can check this inrate_vote_ahah(). I have updated the patch, token will also be passed to the callbacks that have registered to theeventBeforeRateevent.Comment #7
vg3095 commentedUpdated to run the test
Comment #8
ivnishDrupal 7 is EOL. Issue will be closed, but patches are still here