0

I have a stop and a reset button. The stop button enables multiple buttons on the DOM that are disabled when the user hits start. The reset button also enables the same buttons. If the user presses stop and then reset, I'd rather not try to re-enable the same buttons. In fact, I think it may cause some bizarre behaviour.

Is there a way to test if the click event for a button has been re-enabled by, say, the stop button before trying to enable it by the reset button?

$('#stop').click(function() {
    clearInterval(watchHandler);
    clearInterval(breakHandler);
    if (breakInterval !== 1) {
           $('#minusSession').on('click', minusSession);
           $('#plusSession').on('click', plusSession);
    }
    $('#minusBreak').on('click', minusBreak);
    $('#plusBreak').on('click', plusBreak);
    $('#start').on('click', startLogic);
});

function resetLogic () {
     clearInterval(watchHandler);
     clearInterval(breakHandler);
     $('#minusSession').on('click', minusSession);
     $('#plusSession').on('click', plusSession);
     $('#minusBreak').on('click', minusBreak);
     $('#plusBreak').on('click', plusBreak);
     $('#start').on('click', startLogic);
 }
Abhilash Ravindran C K
  • 1,818
  • 2
  • 13
  • 22
Ryan
  • 1,312
  • 3
  • 20
  • 40
  • 1
    use `event.target` to get the the element who triggered the event – guradio Feb 20 '18 at 01:02
  • https://stackoverflow.com/questions/2518421/jquery-find-events-handlers-registered-with-an-object – fqhv Feb 20 '18 at 01:03
  • 1
    Use a variable/flag to set current condition, and/or add/remove some classes to elements for the same cause. – skobaljic Feb 20 '18 at 01:56
  • I don't get it. Enable/disable buttons is just a setting a property for each. Disabling an already disabled button shall not cause an issue. From what you posted, I just can't tell. Please describe more about the *«bizarre behaviour»* and post the relevant functions you have. – Louys Patrice Bessette Feb 20 '18 at 02:33

0 Answers0