JQuery mask does not work for loaded content

when content is loaded using ajax, the mask does not work with the input text.

What should I do?

with thanks

the code:

$.ajax({url: path, data: {action:'create_form_profile'}, timeout:5000, type:"POST", success: function(data) {
    $("#_content").html(data);
    {
        $("#birth_date").mask("9999/99/99");
    }


    $("input:hidden").click(function(event) {
        window.location.href = "logout.php";
        sho‌​w_exit();
    });
}
});
0
source share
3 answers

For me, this works in ajax callback:

$('.phone').unmask().mask(phoneMask);

I do not understand why adding the same mask a second time disables it.

+3
source

fire an input change event after changing its contents via ajax.

if all input comes from ajax, then run the mask plugin and then fire the change event.

IE:

   $("#birth_date").mask("9999/99/99").change();
0
source

I found the reason;)

jquery.hotkeys-0.7.9.min.js was the reason.

I have the following js files:

<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
<!--<script type="text/javascript" src="js/jquery.hotkeys-0.7.9.min.js"></script>-->
<script type="text/javascript" src="js/_links.js"></script> 
<script type="text/javascript" src="js/_mask.js"></script>  
<script type="text/javascript" src="js/_lib.js"></script>
<script type="text/javascript" src="js/_general.js"></script>
<script type="text/javascript" src="js/_jq.js"></script>

and when I deleted the second file it was like that

0
source

All Articles