ol.breadcrumb li =<> link_to "Projetos", licitacao_projetos_path(), class: 'link_breadcrumb' li =<> link_to "Projeto #{@projeto.pedido.numero}", @projeto, class: 'link_breadcrumb' li.active Adicionar Informações = simple_form_for(@projeto, url: licitacao_atualizar_ata_da_carona_path(), method: :patch) do |f| = f.input :cadastrando_ata_da_carona, as: :hidden, input_html: { value: "#{true}" } .widget .widget-body .form-group .row .col-sm-3 = f.input :ata_de_registro_de_precos_original, label: "Ata de Registro de Preço" .col-sm-3 = f.input :orgao_gerenciador_da_ata, label: "Orgão Gerenciador" .col-sm-3 = f.input :estado_id, label: "Estado", collection: @estados, label_method: :uf, include_blank: "Selecione", input_html: { class: "s2", id: "estado" } .col-sm-3 = f.input :cidade_id, label: "Cidade", collection: @cidades, label_method: :nome, include_blank: "Selecione", input_html: { class: "s2",id: "cidade" } .form-actions .row .col-sm-12 = f.submit "Salvar", class: "btn btn-success" = link_to "Voltar", @projeto, class: "btn btn-default" javascript: $("#estado").on("change", function(){ limpaSelectBox("#cidade"); $.ajax({ type: "GET", url:`${root_url}/pesquisas/${$(this).val()}/cidade_por_estado`, beforeSend: function(){ LoadingInterface("Carregando Liquidações...") }, success: function(data, status, xhr){ if($.trim(data) != ""){ $.each(data, function (i, item) { option = new Option(item.nome, item.id, true, true); select_box.append(option); }); populaSelectBox(select_box); } } }) }) function limpaSelectBox(id){ $(id).empty().trigger('change') select_box = $(id).select2({ placeholder: "Selecione", allowClear: true }) return(select_box); } function populaSelectBox(select_box){ select_box.prepend(new Option('Selecione', '', true, true)); select_box.trigger('change'); }