如何操作jquery-bootgrid格式化程序中的元素
How to operate on an element inside jquery-bootgrid formatters
假设我有一个这样的bootgrid格式化器:
$(document).ready(function () {
//bootgrid
$("#bootgrid-issues").bootgrid({
...
formatters: {
product: function (column, row){
return "<p class='per_online_issue_id'>" + row.product["product_name"] +"</p>";
},
category: function (column, row){
return "<p>" + row.category["category_name"] +"</p>";
},
},
});
我希望它打印一个"hello",如果per_online_issue_id
元素点击。但它并没有像预期的那样工作。我错过什么了吗?我是这样做的,我把它写在formatters
后面。
$('.per_online_issue_id').click(function () {
console.log("hello")
});
最后我自己想出了如何通过返回javascript来做到这一点。
首先:从bootgrid的格式化器返回Javascript。
product: function (column, row){
return "<a href='"javascript:void(0)'" onclick=my_function(''"+row.product["product_name"]+"''+ "</a>";
},
第二步:调用返回的my_function
来操作你想要的元素。
<script>
function my_function(product_name) {
alert("product_name returned from bootgrid: " + production_name);
}
</script>
相关文章:
- Highcharts-如何在自定义格式化程序中获得默认的y轴标签格式化程序
- 如何在谷歌可视化中组合数字和模式格式化程序
- 用于用户内容的简单代码编辑器/文本格式化程序(在Rails中)
- 使用jqGrid列格式化程序函数使ng-click工作
- Highcharts:格式化程序和点击功能don'不能使用Angular
- 如何在TiddlyWiki中制作列表格式化程序
- Highcharts xAxis将格式化程序回调数据标记为空
- Angular.js指令格式化程序只调用过一次,或者如何告诉ngModel表现得像watchCollection
- 高图表 - 是否可以为每个系列添加工具提示格式化程序
- jqGrid - 如何通过自定义格式化程序提供多个预定义的格式化程序
- 工具提示格式化程序中的间距错误
- Ruby MySQL格式化程序
- Angular Directive格式化程序/渲染器不更新
- 在thymelaf页面中格式化引导程序日期选择器
- sap.m.按钮文本格式化程序
- 城市FR格式化程序案例
- 在JQGridshowlink格式化程序中添加了动态参数
- SAPUI5 - 格式化程序功能不起作用
- 使用 jquery 编号格式化程序格式化数字并重新格式化它们
- 精细的上传程序格式化代码的问题,事件