ColdFusion.navigate works with non-CF generated UI items

Scott just pinged me with an interesting question - can you use ColdFusion.navigate with a “normal” div or does it only work with items generated by ColdFusion 8 (cfdiv, cfwindow, cfpod, etc)? We both tested and discovered that - yes - you certainly can use it with a “vanilla” div - but you must get ColdFusion to preload the proper JavaScript files. Consider this simple demo:

<cfajaximport />

<script> function doit() { ColdFusion.navigate(‘test3.cfm’,’booger’) } </script>

<a href=”javaScript:doit()”>load the booger</a><br /> <div id=”booger”></div> </code>

Starting from the bottom up - the div, booger, is our container. I have a test link above it that runs the doit function. doit() then simply uses ColdFusion.navigate. If you just use that portion of the file, though, you will get a client-side JavaScript error saying that ColdFusion doesn’t exist. You need to tell ColdFusion to load the the Ajax libraries. This can be done with a simple, empty cfajaximport tag.

Not sure how useful this is, but if you don’t have Spry or jQuery loaded and need a simple and fast way to load data via Ajax, this would work well.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments