Copy link to clipboard
Copied
Following this example Easy Rich Internet Applications With ColdFusion 8 — SitePoint the rowdblclick event does nothing. Same result for the example code and my augmented code. Neither work. Is there a different way of adding a listener in CF2016?
<script type="text/javascript">
function initGrid(){
var grid = ColdFusion.Grid.getGridObject("aaaGrid");
grid.on("rowdblclick", showAAAForm);
}
function showAAAForm(){
var aaaId = ColdFusion.getElementValue("aaaGrid", "gridForm", "id");
var url = "aaaForm.cfm?aaaId="+aaaId;
ColdFusion.navigate(url, "aaaWin");
ColdFusion.Window.show("aaaWin");
}
function submitForm() {
clearErrors();
ColdFusion.Ajax.submitForm("aaaForm", "AAA_submit.cfm", submitCallback, errorHandler);
}
function submitCallback(response){
var errors = ColdFusion.JSON.decode(response);
var valid = true;
for(i in errors){
document.getElementById(i+"Error").innerHTML = errors;
valid = false;
}
if(valid){
ColdFusion.Window.hide("aaaWin");
ColdFusion.Grid.refresh("aaaGrid", true);
}
}
function newAAA(){
var url = "aaaForm.cfm" ;
ColdFusion.navigate(url, "aaaWin");
ColdFusion.Window.show("aaaWin");
}
function errorHandler(code, msg)
{
alert("Error!!! " + code + ": " + msg);
}
function clearErrors(){
document.getElementById("fNameError").innerHTML = "";
document.getElementById("lNameError").innerHTML = "";
}
</script>
I found the solution! Replace rowdblclick with itemdblclick
grid.on("itemdblclick", showAAAForm);
Copy link to clipboard
Copied
You're probably not going to care for my recommendation, but I recommend you avoid using CF's JavaScript UI stuff, especially any examples you see going back to CF 8! JavaScript changes pretty frequently, and JavaScript UI best practices also change frequently, and CF doesn't keep that stuff up to date - I'm not even sure whether they effectively could keep it up to date. Instead, learn JavaScript and JS UI best practices, and write grids etc yourself.
Dave Watts, Fig Leaf Software
Copy link to clipboard
Copied
A colleague confirmed it does work with ColdFusion 10 so something has changed in 2016?
Copy link to clipboard
Copied
Who knows? My point is that this stuff is generally unreliable, and if it didn't break in CF 10 (which is no longer supported) it's likely to break in newer versions. I would not be surprised at all if the included JS libraries in CF 2016 or 2018 are newer than the ones included in CF 10.
Dave Watts, Fig Leaf Software
Copy link to clipboard
Copied
I found the solution! Replace rowdblclick with itemdblclick
grid.on("itemdblclick", showAAAForm);
Copy link to clipboard
Copied
Hi berniemiller, thanks for sharing that. Please mark it as the correct solution. It will help someone else in future.