Copy link to clipboard
Copied
Sorry guys, it appears that my code was not posted correctly on my original post and therefore did not show up.
Please see below for my question/problem. - Thanks!
---------------------------
Hey guys,
Something strange is going on. I am using CF8 and I have multiple records in a table and they all display fine with a table within a cfoutput query="foo". However I want to use cfdiv instead to take advantage of partial page updates.
So I am binding my cfdiv to a cfc and when it runs it only displays the first record. I have had similar problems with using cfoutput query and divs in the past. Is there something about divs that don't allow multiple results to display?
Here is my code:
<cfinvoke component="services.PostService" method="getPosts" returnvariable="post">
<cfinvokeargument name="numberOfRows" value="4">
</cfinvoke>
<cfoutput>
<cfdiv bind="cfc:services.PostService.getPosts(4)">
#post.description# <br />
</cfdiv>
</cfoutput>
Here is my component in case you need to look at it:
<cfcomponent output="no">
<cffunction name="getPosts" access="remote">
<cfargument name="numberOfRows" type="numeric" required="yes">
<cfset var getPosts = "">
<cfinclude template="../dal/qry_getPosts.cfm">
<cfreturn getPosts>
</cffunction>
</cfcomponent>
Thanks for any help you can provide.
Thank you,
Chris
Well here is what I see.
You don't need to invoke the cfc at the start as your bind statement is invoking it for you and you dont need the #post.description# within the cfdiv.
so you end up with
<cfdiv bind="cfc:services.PostService.getPosts(4)"></cfdiv>
second what ever is returned by the cfc function will be displayed within the cfdiv. So returning a query isnt going to work here you need to have your function process the query and return the actual html you want to display.
Hope this helps.
Richar
...Copy link to clipboard
Copied
Well here is what I see.
You don't need to invoke the cfc at the start as your bind statement is invoking it for you and you dont need the #post.description# within the cfdiv.
so you end up with
<cfdiv bind="cfc:services.PostService.getPosts(4)"></cfdiv>
second what ever is returned by the cfc function will be displayed within the cfdiv. So returning a query isnt going to work here you need to have your function process the query and return the actual html you want to display.
Hope this helps.
Richard
Copy link to clipboard
Copied
Thanks for your help man! I really appreciate it!