Change execution order of JavaScript files

1

I'm developing a project that by clicking the button next to the application ASP.NET WebForms runs a dynamic code (this script is built in loading each page, Dynamic.JS - it is translated from C # programming blocks) and then in same event should call the functions referenced in Validacoes.JS. The only problem is in the order of execution. The application calls Validacoes.JS before Dynamic.JS and for the application to behave as expected, Dynamic.JS must be run first. How do I do this?

Calling one function within another would not be a viable solution for me. The name of the function associated with the next button varies from page to page in the Dynamic.JS file

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Validacoes.JS ---> No momento é o primeiro a ser executado... deveria ser executado após o Dynamic.JS
// no ProximoButton esse evento verificacaoProximo está no onclick!


function verificacaoProximo() {
    if (retorno == "avanca") {
        if ($("#HiddenFielPodeAvancarTela").val().toString() == "0") { // PodeAvancar NAO
            if ($("#HiddenFielPodeAvancarTelaFlag").val().toString() == "1")
                retorno = "avanca";
            else
                retorno = "naoavanca";
        }
        else { // PodeAvancar SIM
            if ($("#HiddenFielPodeAvancarTelaFlag").val().toString() == "1")
                retorno = "avanca";
            else
                retorno = "naoavanca";
        }
    }
    return retorno;
}




//Dynamic.JS
$(document).ready(function () {

// HiddenField
if (!document.getElementById("hfcerto") ) {
var input792 = document.createElement("input");
input792.setAttribute("type","hidden");
input792.setAttribute("name", "hfcerto");
input792.setAttribute("value", "0");
input792.setAttribute("id", "hfcerto");
document.getElementById("hfs").appendChild(input792);
}

// HiddenField
if (!document.getElementById("hferro") ) {
var input121 = document.createElement("input");
input121.setAttribute("type","hidden");
input121.setAttribute("name", "hferro");
input121.setAttribute("value", "0");
input121.setAttribute("id", "hferro");
document.getElementById("hfs").appendChild(input121);
}



$("#ProximoButton892").click(function(){
    prox_click();
});

});



function prox_click(){
if((document.getElementById("hfcerto").getAttribute("value")=="8")&&(document.getElementById("hferro").getAttribute("value")=="0")){
document.getElementById("ImageButton1").src = document.getElementById("ImageButton2").src;
}
else if((document.getElementById("hfcerto").getAttribute("value")=="5")&&(document.getElementById("hferro").getAttribute("value")=="0")){
document.getElementById("ImageButton1").src = document.getElementById("ImageButton2").src;
}
else {
document.getElementById("ImageButton1").src = document.getElementById("PictureBoxProp891").src;

var valorHF = document.getElementById("HiddenFielQtdExercErrados").getAttribute("value");
document.getElementById("HiddenFielQtdExercErrados").setAttribute("value", parseInt(document.getElementById("HiddenFielQtdExercErrados").getAttribute("value")) + 1);
}
return false;
}
    
asked by anonymous 08.06.2015 / 13:13

1 answer

1

I will demonstrate with analogy to a simple problem, and see if this can solve your problem.

jQuery has a GUI API, and it only works if jQuery's core is already loaded, so when you call the interface, you first call the core, coding this would be something like

<script src="../js/js_1.9/jquery-1.8.2.js" type="text/javascript"></script> // Primeiro esse
<script src="../js/js_1.9/jquery-ui-1.9.1.custom.min.js?v=01" type="text/javascript"></script> // depois este
    
08.06.2015 / 14:39