Guilherme, são muitos campos a bloquear? São campos pré-definidos para a etapa em questão? Se sim, sugiro encapsular dentro de uma div específica para cada etapa e bloquea-las de acordo com sua necessidade. Faço isso e funciona perfeitamente.
enableContainer($("#" + nomeEtapa)[0], true); bloqueia todos os campos dentro da div
enableContainer($("#" + nomeEtapa)[0], false); desbloqueia todos os campos dentro da div
function disableField($el, disabled){
if(disabled){
$("#" + $el.attr('id') + "_d").hide();
$el.show();
}
else{
($("#" + $el.attr("id") + "_d").length > 0) ? $("#" + $el.attr("id") + "_d").show() : $el.before($el.clone().attr({"id":($el.attr("id") + "_d"),"name":($el.attr("name") + "_d")}).attr("disabled",true));
$el.hide();
}
}
function enableContainer($el, enabled){
$($el).find("input[type='radio'],input[type='text'],input[type='number'],input[type='checkbox'],textarea,select,input[type='button'],img").each(function (i) {
enableField($(this), enabled);
});
};
function enableField($el, enabled){
if($el.attr("type") == "text" || $el.attr("type") == "number" ){
$el.prop("readonly",!enabled);
//se possui botao agrupado desabilita tambem
if(enabled == false){
$el.parent().find('.input-group-addon').css("pointer-events", "none");
$el.parent().find('.in put-group-addon').children().css("opacity", 0.4);
}
else{
$el.parent().find('.input-group-addon').css("pointer-events", "auto");
$el.parent().find('.input-group-addon').children().css("opacity", 1);
}
}
else if($el.prop("tagName") == "TEXTAREA"){
$el.prop("readonly",!enabled);;
}
else if($el.prop("tagName") == "SELECT"){
disableField($el, enabled);
}
else if($el.attr("type") == "button" || $el.prop("tagName") == "IMG"){
$el.prop("disabled",!enabled);
if(enabled){
$el.css("opacity", 1);
$el.css("filter", "");
if($el.data("click-event") != ""){
$el.on("click", $el.data("click-event"));
$el.data("click-event", "");
}
} else {
$el.css("opacity", 0.4);
$el.css("filter", "alpha(opacity=40)");
$el.data("click-event", $el.get(0).onclick);
$el.off();
$el.get(0).onclick = "";
}
}
else if($el.attr("type") == "radio" || $el.attr("type") == "checkbox" || $el.attr("type") == undefined){
var endWithDisabled = new RegExp(/_d$/);
var nameOf = ($el.selector.replace("#","") != "") ? $el.selector.replace("#","") : $el.attr("name");
$el = $("[name='" + nameOf + "']").filter(function(index, element) {
return !endWithDisabled.test(element.id); });
if($el.length && $el.length > 0 && ($el.attr("type") == "radio" || $el.attr("type") == "checkbox")){
$el.each(function(i){
$("label[for^='"+$(this).prop("id")+"']").each(function (i) {
var suffix = (endWithDisabled.test($(this).prop("for"))) ? "_d" : "";
if(enabled){
$(this).prop("for", $(this).prop("for").replace(endWithDisabled,""));
}
else if(suffix == ""){
$(this).prop("for", $(this).prop("for")+"_d");
}
});
disableField($(this), enabled);
});
}
}
}