gpt4 book ai didi

javascript - 当变量值有空格时如何在kendo UI的itemTemplate中渲染JS变量

转载 作者:行者123 更新时间:2023-12-02 23:53:53 30 4
gpt4 key购买 nike

我在 itemTemplate 函数中使用来自服务器的响应数据来创建带有值的复选框列表。我面临的问题是,如果有一个变量的值中有空格,例如:“In Progress”,那么它无法正确渲染。

下面是我的 itemTemplate 函数和数据渲染后的 html 元素。

 itemTemplate: function (e) {
return "<li class='k-item><label class='k-label'><input type='checkbox' value=#= data.Status || data.all # />#= data.Status|| data.all #</label></li>"
}

enter image description here

Here is a demo of the same 。有没有办法呈现数据,以便我可以获取 value 属性内的整个文本?或者我在这里做错了什么?请推荐,谢谢!

最佳答案

您需要添加转义引号,如下所示:

\'#=data.country|| data.all #\'

$("#grid").kendoGrid({
columns: [ {
field: "country",
filterable: {
multi:true,
itemTemplate: function(e) {

return "<li class='k-item><label class='k-label'><input type='checkbox' value=\'#=data.country|| data.all #\' />#= data.country|| data.all #</label></li>"


}
}
}],

关于javascript - 当变量值有空格时如何在kendo UI的itemTemplate中渲染JS变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55502389/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com