1
I’m using the mask option jQuery-Mask-Plugin and I use a field duplication code; however, when duplicating the elemto, the mask does not follow, that is, the new element (duplicated) does not carry the mask of the source element.
Any idea how to make one Reload in jQuery for the mask to be applied?
Follow the fiddle:
Mask Code:
var maskBehavior = function (val) {
return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';
},
options = {onKeyPress: function(val, e, field, options) {
field.mask(maskBehavior.apply({}, arguments), options);
}
};
$('.phone').mask(maskBehavior, options);
jQuery field duplication code:
$(document).ready(function (){
clone_obj = function(obj_name, obj_destination) {
$('#' + obj_name).clone().appendTo('#' + obj_destination).find("input[type='text']").val('');
}
delete_obj = function(obj_name, group) {
$(obj_name).closest('#' + group).remove();
}
});
Excellent! Thanks, solved the problem. Abs!
– Evert
I changed your post with the new jsFiddle, ok?
– Evert
I just put too... but thanks!!!
– Valentim Araújo