Marking in checkboxes select multiselect stopped

0

I'm using the JQuery multiselect plugin from: link .

$(document).ready(function(){

Well, I'm using the function below that checks the marked options

for (i = 0; i < $(".ui-multiselect-checkboxes").length; i++) {  
  $ui = $(".ui-multiselect-checkboxes");
  $indiferente = $ui.find("[title=Indiferente]");
  $indiferente.prop("checked", true);
  $ui.find("input").change(function(){
    if($(this).attr("title") != "Indiferente" && this.checked){
        $indiferente.prop("checked", false); //desmarco indiferente se algum
                                            //outro for selecionado
    }
    if(!$ui.find("input:checked").length){ //se nenhum input estiver marcado
        $indiferente.prop("checked",true); //marco indiferente

    }
  })

  $indiferente.change(function(){                 //quando indiferente mudar
    if(this.checked){                             //se estiver marcado
        $ui.find("input").not("[title=Indiferente]").prop("checked", false);                       
                                                  //desmarco outros
    }           
  })

  $("#ui-multiselect-tipo-option-0").click(); 
  $("#ui-multiselect-bairro-option-0").click();

 }

Obviously I hit the plugin to select fields

$("#tipo").multiselect();
$("#bairro").multiselect();

But the part of the markings stopped working

});

Where did I go wrong?

    
asked by anonymous 28.04.2016 / 14:06

1 answer

1

The embarrassment was arising because when you passed in, there were no objects.

So change.:

$("#tipo").multiselect();
$("#bairro").multiselect();

To start the function.:

$(document).ready(function(){
    
28.04.2016 / 15:30