Reputation: 18908
I'm trying to add a custom formatter to a Dojo DataGrid. This formatter is as far as I understand supposed to return a string with html for presentation.
I want to render a link with a js callback when clicked, i.e
<a href="javascript:void(0)" onclick="callMeBack()">value</a>
The problem is that I don't want to have a global function callMeBack()
, but rather write the callback function inline. But I can't seem to get this to function. So far I wrote this:
function callMeBack() { ... }
var structure = [
{name:"name", field:"name", width: "200px", formatter: function(name) {
var link = domConstruct.create("a", {innerHTML: name});
domAttr.set(link, "href", "javascript:void(0)");
on(link, "click", callMeBack);
return link.outerHTML;
}},
....
];
The problem seems to be that the click callback doesn't get registered. Quite understandable considering that the DOM node used in the grid will probably be constructed after the string representation is returned.
But how can I make this work?
Upvotes: 0
Views: 656
Reputation: 1
One possible way would be to define a function like xx.yy.callmeback GLOBALLY so that the function definition is found. But i dont feel this is the best way.
Upvotes: 0