Emil asks:
Unfortunately there is no built in way to always run a callback for ColdFusion.navigate. Nor is there anyway to do a callback at all for AjaxLink(). What I'd recommend is simply using a wrapper function to handle calling ColdFusion.navigate() and setting up a callback. For example:I was wondering if there is a way to set a global callbackHandler for "Coldfusion.navigate" when using the "AjaxLink()" function. You see, I'm using sIFR and I wanted to put the "sIFR.replace()" inside the callbackHandler-function.
<cfajaximport />
<script>
function load(url,con) {
document.getElementById('loadingdiv').innerHTML = "Loading content..."
ColdFusion.navigate(url,con,handleResult);
}
function handleResult() {
document.getElementById('loadingdiv').innerHTML = ""
}
</script>
<div id="somediv"></div>
<div id="loadingdiv"></div>
<a href="" onclick="javaScript:load('foo.cfm?x=1','somediv');return false">x=1</a><br>
<a href="" onclick="javaScript:load('foo.cfm?x=2','somediv');return false">x=2</a><br>
<a href="" onclick="javaScript:load('foo.cfm?x=3','somediv');return false">x=3</a><br>
This example uses a custom function, load, that simply wraps the setting of a loading message (a bit redundant since ColdFusion.navigate will show a spiner) and calling ColdFusion.navigate with the callback.
Nice and simple I think.