I'm trying to pass a button element to the second function upon completion of first function. I've stepped through it with the debugger tool and the ele button being passed into the callback function is being passed correctly. However, the button element being passed in runThisSecond is returning undefined. Any ideas as to why that might be?
HTML file:
<button type="button" class="btn fruitbtn" data-fruitname= "@item.FruitName"> Add Fruit </button>
JavaScript:
$("$table#Results").on('click', '.fruitbtn', function() {
runThisSecond(runThisFirst($(this)));
})
function runThisFirst (ele, callback) {
swal({
html:true,
title: "Fruits"
},
function(isConfirm) {
callback(ele); //button element is correctly passed in here
}
)
}
function runThisSecond(ele) {
var button = ele; //This is returning undefined
}
runThisSecondas the callback torunThisFirst? If so, I think it should be like this:runThisFirst($(this), runThisSecond)