", { value: response.data.bairros[item].slug, html: response.data.bairros[item].value })); } input.removeAttr('disabled'); }); }); $("#filter_status").on("change", function(e) { let input = $("#filter_value"); input.attr("disabled", "disabled").val(null); $("option", input).filter((i, option) => !!option.value).remove(); for(let item in GLOBAL_VARS.priceRanges[this.value]) { input.append($("", { value: item, html: GLOBAL_VARS.priceRanges[this.value][item] })); } input.removeAttr('disabled'); }); $("#search_form").on("submit", function(e) { e.preventDefault(); if($("#filter_reference")[0].value) { this.action = window.baseUrl + '/imoveis'; return this.submit(); } if(!$("#filter_status")[0].value) { alert("Favor selecionar um tipo de negociação (Comprar/Alugar)"); return; } inputs = []; let finalUrl = $(":input.head-filters", this).map(function(){ this.disabled = true; inputs.push(this); if(!!this.value) { return this.value; } }).get().join('/'); if($("#filter_city")[0].value) { finalUrl += "/" + $("#filter_city")[0].value; $("#filter_city")[0].disabled = true; inputs.push($("#filter_city")[0]); } if($("#filter_location")[0].value) { finalUrl += "/bairro-" + $("#filter_location").val(); $("#filter_location")[0].disabled = true; inputs.push($("#filter_location")[0]); } if(!finalUrl) { finalUrl = "imoveis"; } $(":input", this).map(function(){ if(!this.value) { this.disabled = true; inputs.push(this); } }); this.action = window.baseUrl + '/' + finalUrl; this.submit(); inputs.map(input => input.disabled = false); });