rendering partials into variables, like a cfsavecontent

56 views
Skip to first unread message

funaroma

unread,
Jul 26, 2010, 8:06:25 AM7/26/10
to ColdFusion on Wheels
what if I want to just store the output from a partial into a
variable, instead of actually having it actually rendered?

Use case;

I use a response object to pass back information via AJAX. this
response object allows me to respond to AJAX requests in a unified
fashion, passing back:

1. An event response string, like "getArticle:success" or
"getArticle:notFound",
2. One or more data items, inside a struct, (addData) and
3. One or more HTML strings, inside a struct (addHtml).

So in my controller, I have an if isAjax() block and inside that block
I instantiate my response object, set it's event response string, use
addData() and/or addHtml() to add any additional items that could be
useful in the client-side ajax handler, and then serialize the entire
object to JSON.

In the particular controller call I'm working with, I need to store
the HTML result of a partial into a variable so I can pass it back via
AJAX, long with other info, in my response object.

However when I do this:

htmlRecentDiscussions = renderPartial(partial="recentDiscussions",
rsRecentDiscussions="#rsRecentDiscussions#");

and make a standard call to my page (non-ajax) I don't get the html
stored in my variable; instead, it renders the partial without the
surrounding page layout.

Is there a way to do what I want?

Per Djurner

unread,
Jul 26, 2010, 8:58:03 AM7/26/10
to cfwh...@googlegroups.com
Maybe the "returnAs" argument is the solution?
http://cfwheels.org/docs/function/renderpartial

> --
> You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
> To post to this group, send email to cfwh...@googlegroups.com.
> To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.
>
>

funaroma

unread,
Jul 26, 2010, 11:12:35 AM7/26/10
to ColdFusion on Wheels
Son of a B#$CH I hate getting old. I remember reading about that very
attribute.

Thanks for your help with my Oppenheimer's.

On Jul 26, 8:58 am, Per Djurner <per.djur...@gmail.com> wrote:
> Maybe the "returnAs" argument is the solution?http://cfwheels.org/docs/function/renderpartial
Reply all
Reply to author
Forward
0 new messages