我正在使用scalajs-react,我想隐藏一个bootstrap警告,而不是从DOM中删除它。我找到了这段javascript代码here
$('.alert .close').on('click', function () {
$(this).parent().hide();
})
我错误地将其转换为scalajs-react,代码如下:
.componentDidMount(scope => Callback {
jQuery(scope.getDOMNode()).on("click", null, null, Alert.closed _)
}一个明显的问题是,当我单击它的任何位置(不仅仅是按钮)时,它会隐藏警报。如何翻译这个$('.alert .close')?
发布于 2017-02-03 18:02:31
我只是在on()方法中缺少一个选择器。解决方案是:
jQuery(scope.getDOMNode()).on("click", ".close", null, Alert.closed _)https://stackoverflow.com/questions/42019326
复制相似问题