Suppose I have an bootgrid formatters like this:
$(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>";
},
},
});
And I want it to print an "hello" if the per_online_issue_id
element clicked. But it doesn't work as expected. Have I missed something? Here is how I do this, I wrote it right after the formatters
.
$('.per_online_issue_id').click(function () {
console.log("hello")
});
Finally I myself figured out how to do this by returning javascript.
product: function (column, row){
return "<a href=\"javascript:void(0)\" onclick=my_function(\'"+row.product["product_name"]+"\'+ "</a>";
},
my_function
to operate the element you want. <script>
function my_function(product_name) {
alert("product_name returned from bootgrid: " + production_name);
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.