- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
https://jsbin.com/jigefipiye/edit?html,console,output
我有 2 个模板,一个使用可见和不可见绑定(bind),一个使用 # if () #
<div>Template 1</div>
<div id="to-bind1" data-bind="source: Data" data-template="template1"></div>
<div>Template 2</div>
<div id="to-bind2" data-bind="source: Data" data-template="template2"></div>
<script id="template1" type="x">
<li>
# if (Readonly) { #
<span data-bind="text: Val"></span>
# } else { #
<input data-bind="value: Val" />
# } #
</li>
</script>
<script id="template2" type="x">
<li>
<span data-bind="visible: Readonly, text: Val"></span>
<input data-bind="invisible: Readonly, value: Val" />
</li>
</script>
<script>
var toBind1 = $("#to-bind1");
var toBind2 = $("#to-bind2");
var vm = kendo.observable({
Data: [{
Readonly: true,
Val: "Woot!"
}],
});
kendo.bind(toBind1, vm);
kendo.bind(toBind2, vm);
setTimeout(function() {
console.log('dfs')
vm.get('Data')[0].set('Readonly', false);
}, 5000)
</script>
5秒后,Template2切换到输入框,Template1保持不变
问题是在 template2 中输入被隐藏了我想要实现的是将输入与 span 交换,反之亦然,而不是隐藏它
类似于knockoutJS中的if绑定(bind)的东西https://knockoutjs.com/documentation/if-binding.html
if (and ifnot) play a similar role to the visible (and hidden) bindings. The difference is that, with visible, the contained markup always remains in the DOM and always has its data-bind attributes applied—the visible binding just uses CSS to toggle the container element’s visiblity. The if binding, however, physically adds or removes the contained markup in your DOM, and only applies bindings to descendants if the expression is true.
最佳答案
https://jsbin.com/lavunidapo/edit?html,console,output
这显示了您想要的东西,我认为您想要实现(也许)。它从初始状态更改为只读,并重新呈现两个项目模板。但要做到这一点,我们必须将对象从数组中取出并将其重新插入数组中,以便项目模板再次重新渲染。然后它将运行 JS 部分,如下所示:
var $kendoOutput,
$kendoHtmlEncode = kendo.htmlEncode;
with(data) {
$kendoOutput=' \n <li>\n ';
if (Readonly) {
;$kendoOutput+='\n <span data-bind="text: Val"></span>\n ';
} else {
;$kendoOutput+='\n <input data-bind="value: Val" />\n ';
} ;
$kendoOutput+='\n </li>\n ';
}
return $kendoOutput;
使用上述代码渲染 LI 后,就会设置绑定(bind)。如果绑定(bind)的字段发生变化,绑定(bind)将重新评估。但是更改的内容不会重新渲染模板(即它不会再次运行上面的 JS),您必须替换整个项目才能重新运行上面的脚本。
关于javascript - 剑道用户界面 : How to swap DOM elements by Remove/Add,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59872339/
我有两个剑道 DatePickers 来选择工作的开始和结束日期。作业由多个任务组成,其中包含自己的完成日期(任务在网格中列出,每条记录使用 kendo DatePicker 选择完成日期) 当用户设
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
kendo ui 网格不支持卡住列。如果有人可以帮助定制剑道网格卡住列的脚本,将不胜感激。有什么建议么? 列: [ ] 最佳答案 Kendo UI Grid 将在下一个正式版本 - 2014 年第一季
有谁知道如果更改事件在剑道窗口内,为什么更改事件不触发? 我正在使用 knockout kendo.js。 最佳答案 For Change Event Firing Here is sample
使用剑道 Angular 下拉菜单,我可以设置数据和默认值,但由于某种原因,稍后从可用选项中设置值不起作用? 我有一个基本数据模型 {id:x, value:y}。初始化下拉列表后设置值的正确代码是什
有人成功获得了可与自动完成功能配合使用的模板吗? 我在 site 上试过这个例子: template: '' + '#: data.ContactName ##: data.CompanyName #
我想知道是否有办法让我创建一个“kendo”复选框?我知道没有小部件,但也许有一个我可以应用的类,就像我对文本框所做的那样 as suggested here或者像我在这里所做的那样将复选框缩放到更大
我需要一个 Kendo-UI 网格的下拉列表,并遇到了这个示例: http://codepen.io/jordanilchev/pen/cnkih?editors=001 但在这个例子中,下拉菜单的键
我已将 Kendo 网格上的字体大小更改为 11,这样一来,日期选择器文本框上的日历图标在底部被截断了。当您使用以下代码将鼠标悬停在图标上时,我可以使用 margin-top 将图标向上移动,但是我无
我有一个带有占位符数据的 Kendo UI 日期选择器。这是HTML: 这是JavaScript: var start = $(".datepicker").kendoDatePicker({
有没有可能将剑道 ui 网格的最后一列锁定到最右边?我想让用户始终看到行操作按钮,将它锁定在左侧感觉有点奇怪 最佳答案 请在您的页面中添加以下代码段。 .k-grid-content-loc
我正在使用 Kendo UI 网格,如下所示: function refreshGrid() { $(".k-pager-refresh.k-l
我想使用 Kendo UI 开发一个网站。我可以使用 kendo-ui 的其他资格.但是,我无法在 ASP.NET 中使用文件上传。是否有任何示例代码或文档可以解决这个问题? 最佳答案 这就是它对我有
dataSource.changed 事件是否有效? 实例化我的 Kendo UI 网格后,我将按照此处的文档绑定(bind)更改事件: http://docs.kendoui.com/api/fra
我是 Kendo UI PanelBar 的新手。当用户单击按钮时,我想使用 javacript 扩展面板栏。谢谢你的帮助。 @(Html.Kendo().PanelBar()
我的页面中有一个下拉列表,这是代码: Role: Roles:
我正在使用剑道 slider 。我的要求是,对于每个 slider 值的更改,我都需要更改剑道 slider 的背景颜色。 最佳答案 如果要更改 slider 的背景,可以执行以下操作: $("#sl
你好,我正在使用 asp.net mvc 4 开发一个应用程序,我正在使用 kendo 添加 DataGridView!我有一些麻烦: 我想在 datagridview 的列中添加两个属性 我有一个模
以下代码无效。谁能帮我在这里写 else if 条件? function getMyColumns() { return [{ field: "xxx",
我正在使用 kendo ui 创建一些网格。下面的代码示例是促使我实现的代码示例。我在开发过程中遇到了一个错误,我尝试了一些解决方法,但都没有奏效。 http://dojo.telerik.com/A
我是一名优秀的程序员,十分优秀!