Reputation: 281
i have a function which is called on a onclick. Now it has to be on a onclick as thats when the data is being brought in.. i want to know how i can get it to disable and not be called after its been called once.
function Compare(){
var OldVariants = Variants();
var RequestVariants = ProductRequests();
RequestVariants.forEach(function(req) {
OldVariants.some(function(variant) {
if (variant.Id == req.Id) {
variant.Quantity(req.Quantity);
return true; // Stops the inner loop
}
});
});
}
Upvotes: 0
Views: 209
Reputation: 260
In your function, unbind the click event. Ex:
button.onClick = function({
button.unbind('click');
}
Upvotes: 0