I want to disable and enable a click event of the button after clicking it. Hide and show works. Unbind also works but rebinding does not works. Once the button is disabled it cannot be clicked again. What am i doing wrong here?
<div style="display: inline-block;">
<a href="#" id="btnSubmit" class="icon icon-repeat" aria-hidden="$test.get("test")},${test.get("group")}">
<i class="fa fa-repeat"></i>
</a>
</div>
My script is below. I want to re enable the click event after I successfully receive the response:
<script type="text/javascript">
$('.icon-repeat').on('click', function () {
console.log("The button is clicked")
$.ajax({
type: 'GET',
url: '${createLink(action: 'test')}',
data: {test: test},
dataType: 'text',
beforeSend: function () {
},
success: function (response) {
$('.flashMessage').html(response);
},
fail: function (response) {
}
});
});
</script>