我正在寻找如何通过 href 或网格表(KendoUI)中类似的内容调用 javascript id。
这是 html 模板。
<script id="description-template" type="text/x-kendo-template">
<a id="toggleShowIncident" data-code="#: id #">#: generaldescritpion #</a>
</script>
这是我想调用的函数,
$("#toggleShowIncident").click(function(e){
var data = $(this).data('code');
var splitter = splitterElement.data("kendoSplitter");
splitter.ajaxRequest("#left-pane", "/incidents/ajax/show/" + data);
});
我无法在模板内传递任何其他“#”,因为它会破坏 KendoUI 模板。例如<a href="#" id="id">
请问有什么帮助吗?
最佳答案
您可以在 Kendo 模板中使用 #
,只需像 \\#
一样对其进行转义即可。但这不是你的问题。您必须使用过滤器将点击绑定(bind)到网格,例如:
// Grid initialization
$("#yourgrid").kendoGrid(...);
// Event binding
$("#yourgrid").on("click", ".toggleShowIncident", function() { ...
这样,任何具有 class toggleShowIncident
的元素(包括在事件绑定(bind)后添加的元素,例如在数据源重新加载的情况下)都将监听该事件。您必须将 id
更改为 class 才能沿网格重复它。
关于javascript - 调用Jquery函数-通过ajax加载内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50004335/