我有一个带有自定义列的Kendo UI网格:
columns.Template(@<text></text>)
.Width(50)
.ClientTemplate("#= getDeleteHTML(Id, DisplayLocation) #");
它调用一个js函数来构建html以作为一个表单注入以提交删除:
function getDeleteHTML(itemId, itemName) {
var deleteHtml = "<form action='"+ '@Url.Action("Delete", "ManageLocations")'+"/" + itemId +"' method='post'>"
+ "<input type='image' onclick='return confirm(\"Are you sure you wish to delete: \r\n" + itemName + "?\");' value='Delete' class='delete' src='../Images/transparent.gif'>"
+ "</form>";
return deleteHtml;
}
我想将确认消息分成2行。我已经尝试过\ r \ n和@ Environment.NewLine + itemName,因为我不确定在这种情况下使用了哪个解析器(客户端或服务器)。
我怎样才能做到这一点?
答案 0 :(得分:1)
您是否尝试过将确认移至其他功能
function getDeleteHTML(itemId, itemName) {
var deleteHtml = "<form action='"+ '@Url.Action("Delete", "ManageLocations")'+"/" + itemId +"' method='post'>"
+ "<input type='image' onclick='confirmDelete(" + itemName + ")' value='Delete' class='delete' src='../Images/transparent.gif'>"
+ "</form>";
return deleteHtml;
}
function confirmDelete(itemName) {
return confirm("Are you sure you wish to delete: \n" + itemName + "?");
}