Commit dc0e8d3448262a85d813218d7c78b8d647550a50
1 parent
9076194b
Exists in
master
and in
10 other branches
Fix: double click bug on 'vote-results' event click
Showing
1 changed file
with
13 additions
and
6 deletions
Show diff stats
js/main.js
| ... | ... | @@ -236,12 +236,15 @@ function loadRandomProposal(topic_id, private_token) { |
| 236 | 236 | |
| 237 | 237 | $body.off('click', '.vote-result'); |
| 238 | 238 | $body.on('click', '.vote-result', function(e) { |
| 239 | + | |
| 240 | + var $this = $(this); | |
| 241 | + var $proposalDetail = $this.parents('.proposal-detail'); | |
| 242 | + var $resultsContainer = $proposalDetail.find('.results-container'); | |
| 239 | 243 | |
| 240 | - var $resultsContainer = $('.results-container'); | |
| 241 | - | |
| 242 | - $resultsContainer.toggle(); | |
| 243 | - | |
| 244 | - if($resultsContainer.is(':visible')) { | |
| 244 | + // $resultsContainer.toggle(); | |
| 245 | + // $resultsContainer.toggleClass('hide'); | |
| 246 | + | |
| 247 | + if($resultsContainer.css('display') === 'none') { | |
| 245 | 248 | |
| 246 | 249 | $resultsContainer.find('.loading').show(); |
| 247 | 250 | $resultsContainer.find('.results-content').hide(); |
| ... | ... | @@ -252,6 +255,7 @@ function loadRandomProposal(topic_id, private_token) { |
| 252 | 255 | $resultsContainer.html(resultsTemplate(data)); |
| 253 | 256 | $resultsContainer.find('.loading').hide(); |
| 254 | 257 | $resultsContainer.find('.results-content').show(); |
| 258 | + $resultsContainer.show(); | |
| 255 | 259 | |
| 256 | 260 | // scroll to the end |
| 257 | 261 | $('html, body').animate({ |
| ... | ... | @@ -263,6 +267,7 @@ function loadRandomProposal(topic_id, private_token) { |
| 263 | 267 | } else { |
| 264 | 268 | $('.experience-proposal-container').show(); |
| 265 | 269 | $('.talk-proposal-container').show(); |
| 270 | + $resultsContainer.hide(); | |
| 266 | 271 | } |
| 267 | 272 | |
| 268 | 273 | e.preventDefault(); |
| ... | ... | @@ -370,7 +375,9 @@ function display_proposal(proposal_id){ |
| 370 | 375 | $('.proposal-header').show(); |
| 371 | 376 | $('.make-proposal-container').show(); |
| 372 | 377 | $('.support-proposal-container').show(); |
| 373 | - $('.results-container').show(); | |
| 378 | + $('.results-container').hide(); | |
| 379 | + $('.results-container .loading').hide(); | |
| 380 | + $('.results-container .results-content').hide(); | |
| 374 | 381 | $('.experience-proposal-container').show(); |
| 375 | 382 | $('.talk-proposal-container').show(); |
| 376 | 383 | ... | ... |