这是我的代码,在本地当我从下拉列表中选择值时,选择了更改事件,但是当我把这个代码放在服务器selectionChanged事件中时没有触发。请帮助我有没有替代方案,我从this URL
找到了这个消息**HTML Code**
<select data-bind="options: choices, value: selectedChoice"></select>
<select data-bind="event: { change: selectionChanged }">
<option>A</option>
<option>B</option>
<option>C</option>
</select>
**JS Code:**
var viewModel = {
choices: ["one", "two", "three"],
selectedChoice: ko.observable("two") ,
selectionChanged: function(event) {
alert("the other selection changed");
}
};
viewModel.selectedChoice.subscribe(function(newValue) {
alert("the new value is " + newValue);
});
ko.applyBindings(viewModel);
答案 0 :(得分:0)
问题在于你的jsfiddle url是安全的,而使用过的脚本没有。
Mixed Content: The page at 'https://fiddle.jshell.net/rniemeyer/LBz6d/show/' was loaded over HTTPS, but requested an insecure script 'http://knockoutjs.com/downloads/knockout-2.2.1.debug.js'. This request has been blocked; the content must be served over HTTPS.