0

I'm using scalajs-react and I'd like to hide a bootstrap alert instead of removing it from the DOM. I found this javascript code here

$('.alert .close').on('click', function () {
  $(this).parent().hide();
})

Which I wrongly translated to scalajs-react with the following code:

.componentDidMount(scope => Callback {
    jQuery(scope.getDOMNode()).on("click", null, null, Alert.closed _)
  }

The obvious problem is that it hides the alert when I click anywhere on it (not only on the button). How can I translate this $('.alert .close')?

stackoverflowed
  • 686
  • 8
  • 22

1 Answers1

0

I was just missing a selector in the on() method. The solution is:

jQuery(scope.getDOMNode()).on("click", ".close", null, Alert.closed _)
stackoverflowed
  • 686
  • 8
  • 22