jquery maskMoney function does not work in div loaded via ajax

0

I have a page where I am refreshing with ajax only on div conteúdo . It is configured like this:

div1: I load 2 selects where the user will choose these 2 data (class and bimester)

div 2: I load the application menu (menu.php) end of div 2

div id="content": I load the page that reads the 2 selects and loads the corresponding php page, according to the item chosen in the menu at div2 end div id="conteudo"

On the main page, where I have all these divs, I use the maskMoney function of jquery to mask my inputs only as decimal numbers. When I put an input inside the upper divs (1 and 2) the maskMoney works perfectly. When an input is loaded by ajax within the content div, maskMoney does not work.

Can anyone help me understand why this occurs and how to solve it?

    
asked by anonymous 14.11.2017 / 19:26

1 answer

0

Hello, Regina Apparently it's only working on div's that do not use ajax because you must have used the jquery Mask styling command the moment your page loads. It is now necessary to re-execute the plugin function

Try adding the code that applies the mask to the new component the moment you receive the ajax query return, this should solve your problem.

Edited:

Code:

function AlteraConteudo() {
    var ajax = AjaxF();
    ajax.onreadystatechange = function() {
        if(ajax.readyState == 4) {
            document.getElementById('conteudo').innerHTML = ajax.responseText;
            //Aqui você executa os comandos do plugin novamente
        }
    };
    dados = "classe=" + document.getElementById('classes').value + "&bimestre=" + document.getElementById('bimestre').value + "&ano=" + document.getElementById('ano').value + "&tipo=" +document.getElementById('tipo').value;
    var pagina = document.getElementById('pagina').value;
    ajax.open("GET", pagina + dados, false);
    ajax.setRequestHeader("Content-Type", "text/html");
    ajax.send();
}

Att

Bruno Miquelotto

    
14.11.2017 / 19:35