I've got a page which loads an external js and on the page I've got a function called calculate_totals(). What I want is to call the function calculate_totals() from a function in the external js.
This is a piece of JavaScript which loads in an external js
function selectItemMouse(thisVar) { var searchValue = thisVar.attr('data-name'); thisVar.parent().parent().parent().parent().children('.list').val(searchValue); //alert(thisVar.parent().parent().parent().parent().next().find('input').focus()); thisVar.children().children().each(function() { var dataId = $(this).attr('data-id'); var value = $(this).attr('data-name'); //This change the input of my form $(thisVar).parent().parent().parent().parent().children().children('.'+dataId).val(value); }); $('.customerResults').hide(); calculate_totals(); }
What I want is to call the function calculate_totals() from a function in the external js.And what is a problem? I see you are calling it at the end of your function. And it should work just fine.