Closed wvengen closed 8 years ago
You need to JSON.stringify the params because it's going to just say "Object object" as the fetch_params otherwise
Thanks.
For others reading this: somehow using rendr-handlebar's json
helper didn't work. I needed to cast it to a String
or else the resulting fetch params in the view's data attribute would still be empty.
{{view "foo/list" lazy=true model_name="Product" fetch_params=(jsons product_query}}
with product_query
a simple object like {q: 'bar'}
, and in my handlebars helpers:
/*
* Return object serialized as JSON.
*
* Same as rendr-handlebars' `json` but also cast to a string. Somehow this
* is needed or else it isn't serialized.
*/
jsons: function(object, spacing) {
return String(JSON.stringify(object, null, spacing || 'null'));
}
I'm trying to use a lazy-loaded view using
fetch_params
. With rendr-handlebars in the view:and
params
something like{category_id: 12, q: "bar"}
(a search query). I can't get this lazy view to work.It seems that on the server-side,
fetch_params
are known. On the client, however, they are lost. Looking at BaseView#getAttributes, only non-object parameters are stored in the dom; neither doesfetch_params
become part of fetch_summary. When makingfetch_params
a json-string instead of an object, BaseView#fetchLazy complains.Am I the first to use this functionality, or am I missing something?