Search code examples
coldfusioncoldfusion-11cfclient

When invokeCFClientFunction() function should be used?


As a ColdFusion developer I have never used threading or asynchronous programming model (except ajax). invokeCFClientFunction() is a new function intorduced in cfclient to call coldfusion functions asynchronously. But I am bit confused about when we should use this function. I ran this example from cfclient documentation

<cfClientSettings detectDevice=true />


<cfclient>


<cffunction access="public" name="showCanvasSupport" returntype="void" >
     <cfset evalStr = "document.getElementById('canvas').innerHTML='"                
                       & cfclient.canvas & "'">
     <cfset eval(#evalStr#)>
</cffunction>          


</cfclient>


Canvas support -<b id="canvas"></b><br>
<button onclick="invokeCFClientFunction('showCanvasSupport',null)">
Show canvas support
</button>

I called with out using invokeCFClientFunction() <button onclick="showCanvasSupport()"> , It is also working fine.

So any idea In which cases we we should use it?


Solution

  • I have asked the same question to one of the engineers from Adobe. Here is the blog explaining everything, Why invokecfclientfunction?