Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function _ajax(a, url, acao) {
- var dados = $("#form-pesq").serialize() + '&acao=' + acao;
- return $.ajax({
- type: "POST",
- url: url,
- data: dados,
- cache: false,
- success: function (resposta) {
- $("#" + a).html(resposta);
- },
- // complete: function () {
- // refreshMultiSelect(a);
- // },
- error: function () {
- alert("Erro, tente novamente");
- }
- });
- }
- function refreshMultiSelect(tipos) {//a : nome da variavel, ex: tipo, cidade...
- if (tipos == undefined) {
- alert("Passe o ID do select");
- }
- var m = $("#" + tipos).next(".dropdown-multiselect");
- if (m.length != 0) {
- //info("refresh")
- $("#" + tipos).multiselect('refresh');
- } else {
- $("#" + tipos).multiselect();
- }
- }
- $(document).ready(function () {
- //Radios e buttons
- //$("#pesquisar,#limpar").button();
- //$(".tipo_negoc,#qtd_dorm,#qtd_vaga").buttonset();
- //Cidades
- //Tipo negociacao
- //pré cria os multiselect's
- $("#tipos").multiselect();
- $("#cidade").multiselect();
- $("#bairro").multiselect();
- $("#locacao,#venda").click(function () {
- //chama tipos
- _ajax('tipos', "estrutura/tipo-imov-ajax.php", 'listar_tipo_imov')
- .complete(function () {
- //atualiza multiselect tipos
- refreshMultiSelect('tipos');
- //chama ajax cidades
- _ajax('cidades', "estrutura/cidades-ajax.php", 'listar_cidades')
- .complete(function () {
- //atualiza multiselect cidades
- refreshMultiSelect('cidades');
- //chama ajax bairros
- _ajax('bairro', "estrutura/cidades-ajax.php", 'listar_cidades')
- .complete(function () {
- //atualiza multiselect bairros
- refreshMultiSelect('bairros');
- });
- });
- });
- });
- //Codigo imovel
- $('#cod-imovel').each(function () {
- var default_value = 'Código';
- $(this).focus(function () {
- if (this.value == default_value) {
- this.value = '';
- }
- });
- $(this).blur(function () {
- if (this.value == '') {
- this.value = default_value;
- }
- });
- });
- //Validacoes
- $('.cod-imovel').click(function () {
- $('#cod-imovel').val('').focus();
- });
- $('.faixa1').click(function () {
- $('#faixa1').val('').focus();
- });
- $('.faixa2').click(function () {
- $('#faixa2').val('').focus();
- });
- $("#faixa1,#faixa2").maskMoney({symbol: "", decimal: ",", thousands: "."});
- //Pesquisar listagem
- $("#pesquisar").click(function () {
- setTimeout(function () {
- var dados = $("#form-pesq").serialize() + '&acao=listar_imoveis';
- $.ajax({
- type: "POST",
- url: "estrutura/listagem-ajax.php",
- data: dados,
- cache: false,
- beforeSend: function () {
- //$("#listagem_ajax").html("Carregando ...");
- },
- success: function (resposta) {
- //alert(resposta);
- $("#listagem_ajax").html(resposta);
- $("#destaques").html("");
- },
- error: function () {
- alert("Erro, tente novamente");
- }
- });
- }, 200);
- });
- //Carregando
- $(".loading").hide();
- $(".loading").ajaxStart(function () {
- $(this).show();
- })
- $(".loading").ajaxStop(function () {
- setTimeout(function () {
- $(".loading").hide();
- }, 100);
- })
- $(".loading").ajaxError(function () {
- alert("Atenção!\nPágina não encontrada...");
- });
- $('#limpar').click(function () {
- $("#form-pesq")[0].reset();
- $('#locacao').click();
- ajax.abort();
- });
- //Não tirar desta ordem e daqui
- if ($('#form-pesq').length) {
- $("#form-pesq")[0].reset();
- }
- //inicializa combos
- $('#locacao').click();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement