I want to get the element and the passing value outside the calling function for dropdown change event .methodB need to be called inside methodA. But element and selected value related to methodB can't get inside methodeA unless related change event has been called inside methodA.when I do that to execute the code getting too slow.
(function(document, $) {
var $doc = $(document);
$doc.on('foundation-contentloaded', function(e)) {
var selectedValueA;
var selectedValueB;
$('.class_x').each(function(i, element)) {
$(this).on(“change”, function(event)) {
selectedValueA = event.target.value;
methodA($(this), selectedValueA);
}
selectedValueA = $(this).val();
methodA($(this), selectedValueA);
});
$('.class_y').each(function(i, element)) {
$(this).on(“change”, function(event)) {
selectedValueB = event.target.value;
methodB($(this), selectedValueB);
}
selectedValueB = $(this).val();
methodB($(this), selectedValueB);
});
});
function methodA(element, isSelected) {
if (isSelected == 'a') {
//problem is how to call methodB inside methodA cas element and isSelected related methdB is not inside methodA.
//I can’t call each function related to methodB here as it is taking too much time to execute the code
}
function methodB(element, isSelected) {}
})(document, Granite.$)