简体   繁体   中英

Disable Button After Click for 60 Seconds Even If Browser Refreshes Using Meteor

I have been searching, with tons of trial and error, yet to find a solution for this issue. I have found solutions but nothing that I have been successful at implementing.

I am using Meteor and want to create an input/button that is disabled for 60 seconds once clicked. I can make this part happen but my biggest issue is that refreshing the browser makes the button clickable again.

Is there any way to tie the timer to the user id? Any help would be greatly appreciated. I was reading about Date.now(); and Sugar JS, but was not able to make them work for my application.

you can use the html localstorage. eg:

WHILE CLICKED BUTTON SET THIS.
     localStorage.setItem('status', 1);

While 60 sec complete then apply
     localStorage.setItem('status', 0);

and check everytime when button click weather localstorage is 0 or 1.

if 0 submit else return false. And to get localstorage value use as
localStorage.getItem('status');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM