problem with jquery Mask in dynamic form

Asked

Viewed 250 times

1

Well I set up a dynamic form where I have the 'input' plots. It already with value 1 loaded.

I have another input called value, where I use jquery Mask. It works however when I change the value of the 'input' installments are created other 'input' value, and Mask stops working.

I have no bug log on the console. Follow my code:

<script>
        $(document).ready(function () {
            $('.valores').mask('00.000.000,00', {
                reverse: true
            });
        });
    </script>  

Does anyone know what it can be?

  • 1

    That there is no way, you will have to run the function every time you add a new input, try to change the $(document).ready for $(document).bind('DOMSubtreeModified', function () {. Make sure you...

  • It worked out your way.

  • Fine, I’ll post the answer to make it official

1 answer

1


You will have to load the function every time you add an input (modify the DOM), so use the $(document).bind('DOMSubtreeModified', function(){ });:

<script>
    $(document).bind('DOMSubtreeModified', function () {
        $('.valores').mask('00.000.000,00', {
            reverse: true
        });
    });
</script>  

Browser other questions tagged

You are not signed in. Login or sign up in order to post.