jquery replaceWith implications

Posted by Vlad Ioffe on Stack Overflow See other posts from Stack Overflow or by Vlad Ioffe
Published on 2012-10-13T21:31:56Z Indexed on 2012/10/13 21:36 UTC
Read the original article Hit count: 187

Filed under:
|
|
|

I am using replaceWith for input type=file to handle changes of the file the user wants to upload.

I have this code:

$('#add_cv_input').change(function() {
    // here is some code               
    else {
        alert('put one of this: pdf doc docx');
        $("#add_cv_input").replaceWith('<input id="add_cv_input" type="file"/>');
    }
});

now the problem is that this jquery changed event does not being called after the first time that the user had uploaded the wrong extension.

I don't have a clue why this is happening. Everything works fine if at the first time the user uploads a valid extension and then he changes it to other valid extension.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery