0

I've added some selectboxes to data-role fieldcontain, but even though the append functions are correct, jquery mobile doesn't show properly the selectboxes.

JS:

var container = $("#addprogram").find(".addprogramlist");
container.empty();
// alert(eArray);
for(var i = 1; i <=7; i++)
{
  var day = getDay(i);
  container.append("<label for='day-" + i + "' class='select'>" + day + "</label><select name='day-" + i + "' id='day-" + i + "'>");

      for (var j = 0; j < eArray.length; j++)
      {

        container.append("<option value='" + eArray[j] + "'>" +  eArray[j] + "</option>");

      }
      container.append("</select>");
}

HTML:

<div data-role="page" id="addprogram">

    <div data-role="header" data-position="fixed">
        <h1>Add Program</h1>
        <a href="#" data-rel="back" data-theme="a">Back</a>
    </div><!-- /header -->
    <div data-role="content" class='addprogramcontent'>
       <div data-role="fieldcontain" class='addprogramlist'>
       </div>
    </div>
</div><!-- /page -->
4

1 回答 1

1

我不知道我是否正确理解了您的问题,但这可能是答案:

尝试如下刷新您的选择菜单:

$("select").selectmenu();

工作示例http://jsfiddle.net/PG2bV/54/

编辑

我改变了一点你的代码。这就是我通常如何构建一个选择。

于 2013-06-09T14:05:23.757 回答