User Submitted Tip: Refreshing a CFDIV bound to a CFC

I swear this is something I may have covered before, but I’m not finding it in my archives. Either way, it’s a good tip and I wanted to share it. Markus Wollny was working with a CFDIV tag that was bound to a CFC:

<cfdiv id="ivactid" bind="cfc:article.getCuriVactid()"></cfdiv>

The problem he ran into was refreshing the data in the grid. Normally a bound CFDIV (or other UI item) would ‘listen’ in to a particular form field and notice when it changed. In his case, there was no form field included in the bind.

To get around this, he simply used ColdFusion.navigate on the DIV and switched to a URL version of his CFC:

ColdFusion.navigate('article.cfc?method=getCuriVactid','ivactid')

In order for this to work the CFC has to return a string as a result, and unless the cffunction tag declares it explicitly, you will need to use a returnFormat of plain:

ColdFusion.navigate('article.cfc?method=getCuriVactid&returnFormat=plain','ivactid')

Thanks for sharing this, Markus.

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