0

I'm trying to make a select box with search work with AJAX. I'm using the "bootstrap-select-1.9.3", but i don't know why cant get the information.

Like you see in the "Img1" it's supose to change when i change the select "Job" but show me empty, but when i inspect the page, the information it's there like you see.

what i'm doing wrong?

HTML code

<div class="form-group selectMO" style="padding-left: 10px;">
                            <label for="IdAtividade"><?=get_dicionary('txt_atividade',$_SESSION['lingua'],$conn,$_SESSION['IdEmpresa'])?></label>
                            <section id="intro">
                            <select name="IdAtividade" id="IdAtividade"  class="selectpicker" data-live-search="true">

                            </select>
                            </section>
                        </div>

JS code

$("#IdOrdem").change(function()
{
    var suba =0;
    var id=$(this).val();
    $.ajax
    ({
        type: "POST",
        url: 'maoDeObra/ajax_funcoes.php',
        data: {"functionName":"atividade","IdOrdem":id},
        cache: false,
        success: function(html)
        {
            $("#IdAtividade").html(html);
        }
    });

Img1

Insane Skull
  • 9,220
  • 9
  • 44
  • 63
  • could you post the relevant JS code as well, also if possible create a jsfiddle, as it would be easy to fix it ,http://jsfiddle.net – dreamweiver Dec 29 '15 at 11:41
  • on success of the ajax, the html in response has – Anil Panwar Dec 29 '15 at 11:47
  • it's a little bit complicate use de jsFiddle, because i'm using php and AJAX – Tiago Rocha Dec 29 '15 at 11:48
  • @AnilPanwar yes, like i show in the Img1 the select options have values – Tiago Rocha Dec 29 '15 at 11:49
  • Not able to interpret your statement : "Like you see in the "Img1" it's supose to change when i change the select "Job" but show me empty, but when i inspect the page, the information it's there like you see." Can you please elaborate more. – Anil Panwar Dec 29 '15 at 11:57
  • @AnilPanwar When I select an option from the "select Job" is supposed to change the values that are in the "Select Activity / part". But the values are there, as you can see on the right side of the image, but the "Select Activity / part" does not appear. – Tiago Rocha Dec 29 '15 at 12:01
  • It is because you have not put the selected attribute to – Anil Panwar Dec 29 '15 at 12:05
  • Get the HTML which is coming in the response and put attribute selected to the – Anil Panwar Dec 29 '15 at 12:09
  • @AnilPanwar But when i do a normal select works. – Tiago Rocha Dec 29 '15 at 12:11
  • Normal select means? – Anil Panwar Dec 29 '15 at 12:14
  • without search, a simple HTML select – Tiago Rocha Dec 29 '15 at 12:15
  • You question is not clear to me. I would like to help but without fiddle or proper sample code its getting difficult to understand the problem. – Anil Panwar Dec 29 '15 at 12:18
  • 1
    I have found [this question](http://stackoverflow.com/questions/23259617/how-to-add-option-values-on-silviomoretos-bootstrap-select) this will help you in getting it referesh – Ahmed Khan Dec 29 '15 at 12:31

1 Answers1

0

need to refresh the select picker $('#SelectID').selectpicker('refresh');