我有一個彈出框中的選擇框,我沒有任何問題地分配一個初始值。但是,當我打開彈出窗口時,我想要更改選擇框的值,儘管它會「更改」已更改的值,但它不會顯示在選擇框中,除非我再次打開並關閉彈出窗口。任何解決方案,使選擇框更新,以便當我第一次打開彈出窗口分配的值顯示?以編程方式更改模型時選擇框未更新
注:在生產中我使用angularJs來填充選擇框和jqmobile來呈現它。
這裏是小提琴和代碼:https://jsfiddle.net/AKMorris/ufcasngf/6/
<button ng-click="openPopup()">open popup</button>
<div data-role="popup" id="mypopup" data-overlay-theme="d" data-theme="none">
<select id="fcComparator"
ng-model="ccEditorFcComparator"
ng-options="fcEnumComp for fcEnumComp in ccEditorDefaultComparators"
>
</select>
</div>
的JS:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.ccEditorDefaultComparators = ["=","!="];
$scope.ccEditorFcComparator = "!=";
$scope.openPopup = function()
{
$('#mypopup').popup();
$('#mypopup').popup('open', { y: 0 });
console.log("should switch to = now");
$scope.ccEditorFcComparator = "=";
//this makes it work the second time you open the popup
$('#fcComparator').selectmenu('refresh');
}
});
通過檢查'select'我看到在標記中具有兩個選項「選擇= 「選擇」 – deblocker