0
Personal explaining a little how the system works.
When the user enters a value below the established goal, it automatically opens a modal to fill in an "action plan".
By completing the plan, he can create other actions or conclude, but if he leaves it open, every time he enters that place, another modal will appear stating that there is an open plan.
If the user closes the system and comes back to analyze this plan, the right serious: It appears that "Modal Info" he click the button and would take it to the plan page.
Err: When I came back I don’t know what the hell I did, Onclick went automatic. As soon as it enters the area, the system detects that it has an open plan, and already opens its page. Follow the code of the function below.
function showModals(indicadorID, name, city, month, year, role){
checkPlan(name, city, year, function (result) {
//Exemplo de operacao
//mes a definir em indicadorForaDaMeta
checkIndicadorMeta(name, city, month, year, role, function (indicadorForaDaMeta) {
var mesAtual = new Date().getMonth();
if (result.length == 0) {
var mesDoUltimoPlano = mesAtual - 1;
} else {
var mesDoUltimoPlano = new Date(result[result.length - 1].pla_data).getMonth();
}
console.log(result);
if (indicadorForaDaMeta && !(mesAtual == mesDoUltimoPlano)) {
$('#add-modal-plano-de-acao-form').find('[name="id"]').val(indicadorID);
$('#add-modal-plano-de-acao').modal('show');
} else {
for (let i = 0; i < result.length; i++) {
if (result[i].pla_status) {
var month = new Date(result[i].pla_data).getMonth() + 1;
var year = new Date(result[i].pla_data).getFullYear();
$('#info-modal-plano-de-acao-form').find('[name="id"]').val(result[i].pla_id);
$('#info-modal-plano-de-acao-form').find('[name="month"]').val(month);
$('#info-modal-plano-de-acao-form').find('[name="year"]').val(year);
$('#info-modal-plano-de-acao').modal('show');
console.log("#" + convertNameToId(name) + "-botao-plano");
$('#' + convertNameToId(name) + '-botao-plano').removeAttr('onClick');
$('#' + convertNameToId(name) + '-botao-plano').attr('onClick', abrirPlano(result[i].pla_id, month, year));
i = result.length;
}
}
}
});
});
}
.attr('onClick'
is not the correct way to assign code to the click event. In jquery, which seems to be what you are using, you should do.on('click', function() {....}
, or in the old version.click(function(){ ... }
. In the sequence of this the.removeAttr('onClick')
would be.unbind('click')
– Isac
@Isac thank you. I made the changes you suggested and it worked, it’s no longer automatic, but... The Madal button is working, but another button is not. Follow the code. //code <button class="btn-Warning btn-lg" id="example-flat-button">Action Plan</button>
– Letimberg