Jquery mobile选择菜单选项设置动态生成但未设置选项

问题描述:

这里我定义了代码和应用程​​序的屏幕截图。 图片1(我的应用程序) - 这是我的应用程序的输出。我想在选择菜单中显示选定的选项。Jquery mobile选择菜单选项设置动态生成但未设置选项

图片2(我的应用程序) - 当我点击任何选择选项菜单它像这样。但我想设置位置选择。

图片3(需要这个) - 我需要这种类型的我的应用程序的输出。

当我使用本地网络的服务我得到了相同的输出图像3.But当我使用网络服务在线,或从网站我有相同的输出图像-1和图像2。

enter image description here

enter image description here

enter image description here

<body> 
<div id="menu"> 
<h3>Menu</h3> 
    <ul> 
     <li class="active"><a href="home.html?l=0=c=0=d=0=t=1=dc=1" class="contentLink" target="_self">Home </a></li> 
     <li class="none"><a href="myreservations.html" target="_self" class="contentLink">My Reservations</a></li> 
     <li class="none"><a href="#" target="_self" class="contentLink">Credit Points</a></li> 
     <li class="none"><a href="myprofile.html" target="_self" class="contentLink">My Account</a></li> 
     <li class="none"><a href="aboutus.html" target="_self" class="contentLink">About Us</a></li> 
     <li class="none"><a href="contactus.html" target="_self" class="contentLink">Contact Us</a></li> 
     <li class="none"><a href="#" class="contentLink" id="Logoutbutton" name="Logoutbutton">Logout</a></li> 
    </ul> 
</div> 

<div data-role="page" id="home" class="pages" data-theme="c"> 
<div data-role="header"> 
    <a href="#"class="showMenu" id="showMenu"></a> 
    <a id="selectcity" style="line-height:18px;"><select name="selectcity_menu" id="selectcity_menu" data-native-menu="true" data-theme="c" > 
     </select></a>    
    <a id="directlogin">LogIn</a> 
     <h1></h1> 
    </div><!-- /header --> 

    <div data-role="footer">   
    <div data-role="navbar"> 
     <ul> 
      <li><a href="home.html?l=0=c=0=d=0=t=1=dc=1" id="Restaurant" target="_self">Restaurant</a></li> 
      <li><a href="home.html?l=0=c=0=d=0=t=2=dc=1" id="Lounge" target="_self">Lounge</a></li> 
      <li><a href="home.html?l=0=c=0=d=0=t=3=dc=1" id="Banquet" target="_self">Banquet</a></li> 
      <li><a href="home.html?l=0=c=0=d=0=t=4=dc=1" id="Event" target="_self">Event</a></li>   
     </ul> 
    </div><!-- /navbar --> 
    </div><!-- /footer --> 

    <div data-role="content" align="center"> 
     <!--<input type="text" id="userstatus" name="userstatus"/>-->  

     <div class="ui-grid-a"> 
      <div class="ui-block-a"> 
       <div id="notation" style="width:100%;line-height:15px;padding:0px;">  
       <!--<label for="select-choice-0" class="select" ><h2> Locations </h2></label>--> 
       <select name="note_utilisateur1" id="note_utilisateur1" data-native-menu="true" data-theme="c"> 
       </select> 

       </div> 
      </div> 
      <div class="ui-block-b"> 
       <div id="notation" style="width:100%;line-height:15px;padding:0px;">  
       <!--<label for="select-choice-0" class="select"><h2> Cuisine </h2></label>--> 
       <select name="note_utilisateur2" id="note_utilisateur2" data-native-menu="true" data-theme="c"> 
       </select>     
       </div>    
      </div>     
     </div> 

     <div class="ui-grid-a"> 
      <div class="ui-block-a"> 
       <div id="notation" style="width:100%;line-height:15px;padding:0px;">  
      <!--<label for="select-choice-0" class="select"><h2> Discount </h2></label>--> 
       <select name="note_utilisateur3" id="note_utilisateur3" data-native-menu="true" data-theme="c"> 
       </select>     
       </div> 
      </div> 
      <div class="ui-block-b"> 
       <a data-role="button" style="width:94%;line-height:15px;padding:0px;" id="clearall">Clear All</a> 
      </div>     
     </div>   

     <hr /> 

     <br /> 

     <div id="restaurantlist"> 
     </div>  
    </div> 
</div> 
</body> 

所有下拉从Web服务动态生成的菜单选项。

+0

你解决了这一个...... – Aravin

这是行不通的?

这里是JQM文档:

JS

// dummy options 
var optionList = '<option value="1">Location 1</option><option value="2">Location 2</option><option value="3">Location 3</option>'; 

var myselect = $('#note_utilisateur3'); 

myselect.html(optionList); // adding the dummy options 
myselect[0].selectedIndex = 2; // selecting the 2nd index (remeber they start at zero) 
myselect.selectmenu('refresh', true); // http://jquerymobile.com/demos/1.2.0/docs/forms/selects/methods.html 

使用你的问题的HTML

+1

你的解决方案是静态data.When工作当我试图在选择菜单中添加选项通过ajax调用它不工作 – Jay

+0

当我使用192.132.1.23/ web服务/像阿贾克斯的IP地址称其也工作,但是当我使用www.abcxyz.com/webservices/它不工作。 – Jay

+0

可能需要http:// URL的前缀? –