选择中的HTML第一个选项是否是Jquery mobile页面上的渲染选择项目?

时间:2013-12-03 19:38:20

标签: javascript jquery html json jquery-mobile

当我将json绑定到html时我遇到html选择问题选择当我第一次加载页面时它不会显示网页上的第1项

enter image description here

Html

 <div data-role="collapsible-set" id="poset">
<div data-role="collapsible" data-collapsed="false">
<h3>OP Select</h3>
<div class="ui-grid-b">
   <div class="ui-block-a">
      <div style="padding-top: 15px;">Vendor #</div>
   </div>
   <div class="ui-block-b">
      <select id="vendorno">
      </select>
   </div>
   <div class="ui-block-c">
      <button type="submit" id="chooseVendor">Select</button>
   </div>
</div>
<div class="ui-grid-b" id="poGrid">
   <div class="ui-block-a">
      <div style="padding-top: 15px;">PO #</div>
   </div>
   <div class="ui-block-b">
      <select id="POno">
      </select>
   </div>
   <div class="ui-block-c">
      <button type="submit" id="choosePONum">Select</button>
   </div>
</div>

javascript

$('#poGrid').hide();
$('#poInfos').hide();
var rootURLgetVendornosList = "webresources/vendors/getVendornosList";
//var rootURLgetVendornosList = "http://:8080/Info5059Case2v-war/webresources/vendors/getVendornosList";


$.getJSON(rootURLgetVendornosList,null,function(data,status,jqXHR){
        renderVendorList(data);
    }).error(function(jqXHR,textStatus,errorThrown){
        console.log(textStatus+"-"+errorThrown);
    });
//bind select #vendorno
function renderVendorList(data)
{
    $(data).each(function(){
        $('#vendorno').append("<option>"+ this +"</option>");
    });
}




var rootURL3 = "webresources/PO/";
//var rootURL3 = "http://:8080/Info5059Case2v-war/webresources/PO/";


//bind select op select 
 $("#chooseVendor").click(function(){
    $.getJSON(rootURL3 + "getALLPOForVendor/" + $('#vendorno').val(),null,function(data,status,jqXHR){
        renderPOList(data);
    }).error(function(jqXHR,textStatus,errorThrown){
        console.log(textStatus+"-"+errorThrown);
    });

});//chooseVendor
//bind select POno
function renderPOList(data)
{
        $(data).each(function(){
        $('#POno').append("<option>"+ this.ponumber +"</option>");
    });
     $('#poGrid').show();
}

1 个答案:

答案 0 :(得分:2)

将项目附加到选择菜单后,您需要重新增强/重新应用JQM样式。如需选择菜单,请拨打以下电话。

$(".selector").selectmenu("refresh");

参考:Selectmenu widget API