我在弹出窗口中有一个选择框,我分配了一个初始值,没有任何问题。但是,我想在打开弹出窗口时更改选择框的值,问题是尽管它“勾选”了更改的值,但除非我再次打开并关闭弹出窗口,否则它不会在选择框中显示它。有什么解决方案可以更新选择框,以便在我第一次打开弹出窗口时显示分配的值?
注意:在生产中,我使用 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');
}
});