Checkbox marking select multiselect stopped

Asked

Viewed 76 times

0

I am using the multiselect Jquery plugin : http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/#basic.

$(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 linked the plugin to select fields

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

But the marking part stopped working

});

Where I went wrong?

  • Hello, On the console what error does it give? It can replicate constriction for example in jsfiddle for better analysis?

  • Hi, I noticed that if I close }): before $("#type"). multiselect(); the problem stops. But I can’t understand.

  • No errors on console.

  • ok, put $("#type"). multiselect(); $("#neighborhood"). multiselect(); before for. Should work.

  • Thanks, it worked out! Can you help me with this other question by doing favor? http://answall.com/questions/124948/como-definir-focus-no-jhtmlarea/125656#125656

1 answer

1


The embarrassment was arising because when it passed in the was there were no objects.

So change.:

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

For the start of the function.:

$(document).ready(function(){
  • hum, got it. Can you help me out on this one too, please? http://answall.com/questions/124948/como-definir-focus-no-jhtmlarea/125656#125656

Browser other questions tagged

You are not signed in. Login or sign up in order to post.