2012-11-16 168 views
1

這裏我定義了代碼和應用程​​序的屏幕截圖。 圖片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

回答

0

這是行不通的?

這裏是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的前綴? –