jquery - ASP.NET-MVC/Datatables.net 中的按钮无法工作
问题描述
我有点困惑,因为 google chrome 浏览器没有显示语法错误。该按钮已呈现但不起作用。
"render": function () {
return "<a class='btn btn-outline-dark btn-sm' onclick= location.href = '@Url.Action("InterfaceRuntime", "Interface")'><i class='fas fa-play-circle'></i> Run</a>";
},
编辑:
感谢好的建议,我尝试了转义字符,它对我来说非常好。
"render": function () {
return "<a class='btn btn-outline-dark btn-sm' onclick= \" location.href = '@Url.Action("InterfaceRuntime", "Interface")'\"><i class='fas fa-play-circle'></i> Run</a>";
},
解决方案
您可以尝试在 onclick 代码周围添加引号,如下例所示:
"render": function () {
return "<a class='btn btn-outline-dark btn-sm' onclick=\"location.href = '@Url.Action("InterfaceRuntime", "Interface")'\""><i class='fas fa-play-circle'></i> Run</a>";
},
如果这不能解决问题,请打开 chrome 开发者控制台并查看是否有任何错误。
推荐阅读
- node.js - 尝试在 TypeScript 中添加监听事件
- excel - 如何在 Excel 中生成 n 个介于 -100 到 100 之间且总和为零的随机数?
- javascript - 循环遍历两个字符串数组并将它们设置为对象属性
- javascript - 使用 Mocha 和 Chai 进行 REST API 测试 - 未处理的承诺拒绝
- rust - 如何用新格式化的字符串替换字符串切片 Vec 中的一个元素?
- swagger-2.0 - openapi 是否支持复杂类型的默认值?
- javascript - 用 javascript 构建一个文字处理器
- r - 如何在应用函数中使用 cor.test?
- reactjs - 无法理解如何从映射元素接收值
- java - 编组错误:javax.xml.bind.JAXBException:此上下文已知类或其任何超类