I have a div element in my html code with the class name ".myButton" which holds a data object called
data-action="myFunctionToCall"
HTML
<a href="#" class="myButton" data-action="startPaymentOverAction">Start Over</a>
I also have a jquery document ready object that has my button event inside it.
$(function() {
function myFunctionToCall( arg ){
console.log("FUNCTION CALLED");
}
$('.myButton').click(function( event ){
var action = $(this).data('action');
event.preventDefault();
if(action){
document[action](event);
}
});
});
The problem is I can only get this function to work if I use eval. documentaction; will not work I get the error "Uncaught TypeError: document.paymentOptionAction is not a function". How can I get around this without using eval.