Could you please advise how to disable /enable the click function using jquery api. Based on the role i have show the sports page to the user.
Using below bootstrap code for UI.
<div id="viewtest" class="btn-group btn-group-sm">
<button id="C" class="btn btn-default" title="Cricket">Cricket</button>
<button id="B" class="btn btn-default" autofocus="autofocus" autofocus title="BaseBall">BaseBall</button>
<button id="T" class="btn btn-default disabled" title="Tennis">Tennis</button>
<button id="G" class="btn btn-default disabled " title="Monthly">Golf</button>
</div>
I am using below function to handle the above buttons click events.
$(".btn-group > .btn").click(function () {
$(this).addClass("btn-primary").siblings().removeClass("btn-primary");
viewtype = this.id;
$(this).blur();
showPage();
});
For some criteria , i am disabling the click event using below function
var disableOptionsTabs=["C","T"];
disableButtons(disableOptionsTabs);
function disableButtons(mybuttons) {
$.each(mybuttons, function (key, value) {
$("#" + value).off();
});
}
Please advise how to enable the click event? or how to bind the click function for button.
I am using below method ,bind the click event for the specify buttons based on given advise . but it's not working.
var enableOptionsTabs=["C","T"];
enableButtons(enableOptionsTabs);
function enableButtons(mybuttons){
$.each( mybuttons, function( key,value )
{ $( "#" + value ).on("click",myOnClick); }
);
}