【问题标题】:set knockout checkbox label css-cursor from pointer to not-allowed将剔除复选框标签 css-cursor 从指针设置为不允许
【发布时间】:2018-05-10 16:24:38
【问题描述】:

SelectAllActiveEnabled 为真时,复选框是可点击的,css 光标值为指针。当 SelectAllActiveEnabled 评估为 false 时,复选框不可点击,但 css 光标值仍然是指针。如何将其设置为不允许?

<label>
    <input type="checkbox" data-bind="checked: selectAllActiveReleases, enable: SelectAllActiveEnabled" />
    @Html.GetTranslation(Center.Infrastructure.TranslationSources.Center_Web_Orders_ReleaseFull_ReleaseOverview_LabelSelectAllActiveReleases)
</label>

【问题讨论】:

  • 使用:enabled CSS 选择器修改光标。不要为淘汰赛而烦恼。
  • input[type=checkbox]:disabled { cursor: not-allowed; }

标签: html css knockout.js


【解决方案1】:

如果您正在寻找“纯淘汰”解决方案,您应该使用 style 绑定,如下所示:

<input type="checkbox" data-bind="checked: selectAllActiveReleases, enable: SelectAllActiveEnabled, style:{'cursor': cursorForCheckbox()}" />

您必须将cursorForCheckbox 引入您的视图模型。像这样的:

self.cursorForCheckbox = ko.pureComputed(function() {return self.SelectAllActiveEnabled() ? 'pointer' : 'not-allowed';});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多