0

我的单选按钮的 html 是:

<div class="slds-form-element" style="text-align:center;">
    <div id="radio-wrapBorder" style="border-top: 2px solid #f48942;"></div> 
    <label class="slds-form-element__label" for="radio-wrap" style="color: white; font-size: 15px; margin-top: 5px;">Allow Users To Control Their Drag And Drop Settings:</label>             
    <div class="slds-form-element__control">
        <div id="radio-wrap">
            <input type="radio" class="k-radio" id="radioDisableDragDrop" value="DisableAll" name="radioGroup" data-bind="checked: radioDragDrop" style="margin-top: 5px; margin-bottom: 15px;"/><label for="radioDisableDragDrop" class="k-radio-label" id="radioDisableDragDropLabel" style="color: white;">Drag and Drop <b>DISABLED</b> for all users. This will not show up as an option in user settings.</label><br />
            <input type="radio" class="k-radio" id="radioEnableDragDrop" value="EnableAll" name="radioGroup" data-bind="checked: radioDragDrop" style="margin-top: 5px; margin-bottom: 15px;"/><label for="radioEnableDragDrop" class="k-radio-label" id="radioEnableDragDropLabel" style="color: white;">Drag and Drop <b>ENABLED</b> for all users. This will not show up as an option in user settings.</label><br />
            <input type="radio" class="k-radio" id="radioUserDragDrop" value="EnableUser" name="radioGroup" data-bind="checked: radioDragDrop" style="margin-top: 5px; margin-bottom: 15px;"/><label for="radioUserDragDrop" class="k-radio-label" id="radioUserDragDropLabel" style="color: white;">Drag and Drop determined by user preferences.</label>
        </div> 
    </div>
</div>

我的绑定 observable 是:

var radioObservable = kendo.observable({ radioDragDrop: null });
kendo.bind($('#radio-wrap'), radioObservable);
radioObservable.set('radioDragDrop', 'EnableUser');
console.log(radioObservable);

在单选按钮正确的地方,最初选择我传递给 radioObservable.set() 方法的任何内容。但是,当我选择不同的选项并单击保存时... radioDragDrop 仍然是“EnableUser”。

当您选择 3 个单选按钮的不同选项时,任何人都可以看到此绑定有什么问题会导致 radioDragDrop 不更新?

4

1 回答 1

0

我创建了一个演示,单选按钮与可观察对象的绑定似乎工作正常。

这是一些代码片段:

JS:

var radioObservable = kendo.observable({ radioDragDrop: null });
kendo.bind($('#radio-wrap'), radioObservable);
radioObservable.set('radioDragDrop', 'EnableUser'); //default checked option
//radioObservable.trigger('change');
console.log(radioObservable);

$('#save').click(function () {
  alert('current selected option = ' + radioObservable.get('radioDragDrop'));
});
于 2017-09-29T07:46:39.520 回答