2
I got a parole like that:
// 1.º - Verificar se existe a matrícula no sistema
function existeColaborador()
{
if(DSdetalhesColaborador.values[0] == undefined)
{
//alert('Matricula inválida');
limpaCampos();
return false;
}
else
{
if ((DSibrr.values.length < 1) && (DSdetalhesColaborador.values[0]['Situacao'] == 'A'))
{
return true;
}
}
} // fim da função
And then down in the code I have my function:
if(existeColaborador() == false)
{
alert('Não existe Colaborador com essa matrícula')
}
else
{
// DSdetalhesColaborador.values[0]['Situacao'] = 'D';
if (tipoSolicitacao == 'complementar')
{
if (DSdetalhesColaborador.values[0]['Situacao'] == 'A')
{
alert("Não é possível realizar uma Rescisão Complementar para um Colaborador ATIVO!");
limpaCampos();
}
else if (DSdetalhesColaborador.values[0]['Situacao'] == 'D' && DSibrr.values.length > 0)
{
if (DSdetalhesColaborador.values[0]['Situacao'] == 'D' && DSibrr.values[0]['tipoSolicitacao'] == 'complementar')
{
Ext.Msg.show({
msg: "Colaborador já está em processo de demissão no ECM. Iniciar novo Processo Complementar para o colaborador?",
buttons: Ext.Msg.YESNO,
icon: Ext.MessageBox.ERROR,
fn: function(btn) {
console.log(arguments);
if (btn == 'yes') {
preencheCampos()
}
else
{
limpaCampos()
}
}
});
//alert('O Colaborador já teve um processo demissão iniciado ou finalizado no ECM!');
//preencheCampos();
}
else if (DSdetalhesColaborador.values[0]['Situacao'] == 'D' && DSibrr.values[0]['tipoSolicitacao'] == 'desligamento')
{
preencheCampos();
}
}
else
{
alert('O Colaborador ainda não tem um processo demissão iniciado ou finalizado no ECM!');
preencheCampos();
}
}
} // fim da condicional
It turns out that in Chrome everything works fine, but in firefox error occurs saying:
existeColaborador is not defined.
Is there any problem in calling a function within a conditional?
image shows my code
Because there’s a change of identation on line 478?
– Sergio
In line 478 there is an instructive comment. Above it I consume web services and store the values in objects. Later I need to make a series of comparisons of these values, because I depend on various information of these webservices. Example: I enter the employee registration, if this employee == fired, I do not allow you to resign.
– durtto
Do you want to solve the problem or know why it’s going wrong just in the
firefox
?– Jéf Bueno
Okay, Sergio, after I correct the tab, but now I need to understand why firefox does not recognize the function. help me.
– durtto
I want to understand @Jéfersonbueno, understood I seek the fix.
– durtto
You have how to post the full code of functions?
– Jéf Bueno
@Eduardoseixas but I see no reason to change the indent after a comment... You can reproduce the problem in jsFiddle for example?
– Sergio
@Eduardoseixas, post the function code. We have no way to guess what is causing the error...
– Jéf Bueno
Try passing the function over the code that calls it. Also try clearing the browser cache and inspect if your code has been updated.
– Joao Paulo
OK @Joaopaulo I will try to do this, but I want it to work regardless of where the function is... It could even be in another file, it should run, because, remembering, it runs on 'Chrome' but does not work on 'firefox'.
– durtto
Passing the function up solved. But because firefox does not understand in the same way as Chrome?
– durtto
@Eduardoseixas If possible, we need all the code from Rules.js, if it is not too difficult to guess by looking only at the image. As we know the browser reads the entire file before running so the problem may be elsewhere than you can imagine, so we need to see all the code to give you an answer.
– Erick Gallani
It’s a lot, but okay....
– durtto
[follow Rules] (http://jsfiddle.net/Durtto/4u82whaf)
– durtto
@Eduardoseixas check your browser version and more importantly if by chance there is no other javascript that happens to have another function or variable with the same name of this function. Because I ran here in firefox only the chunk with error, and it works normally (it does not from Function Undefined error) even with me passing its validation function to after if, because in javascript this is irrelevant since Function is in the same closure of if.
– Erick Gallani
Run a simple test. Rename the function to something that you can be sure is not nearly impossible to use on the system, for example testadasd() and see if the error continues.
– Erick Gallani
I changed yes, but it won’t help anyway. Check out this answer. firefox doesn’t really support block function statement.. http://stackoverflow.com/questions/25111087/why-is-a-function-declaration-within-a-condition-block-hoisted-to-function-scope
– durtto