-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this.collection is empty on client side code when initial page render is on server #399
Comments
No 100% sure but give this a try: {{ view 'listing/list-single' _model=this }} |
I believe you would actually want to do something like: {{#if _collection.length}}
{{#each _collection.models}}
{{ view 'listing/list-single' model=this }}
{{/each}}
{{/if}}
|
Thanks to both of you, @bigethan and @mikepuerto . Neither of your solutions solved the issue. I suspect this issue arose when a view is called from another view. I also have another page where I show a single listing, and I can access this.model in both server and client on that page. I still cannot access this.model in list.hbs though if the initial page render is on server. (I can access it in my 2nd search, when rendering takes place in the client) |
That's odd. I am actually doing this exact same thing and it works like a charm. Is it actually rendering the subviews? I have actually seen this issue before where it worked in one place and not another... turned out to be error on my part though... What version are you using? |
this is the version I am using: git://github.com/rendrjs/rendr.git#c599674a87f9044da959d5f2381147f5ce95aebe. What is yours? |
My further examination showed that I can access the attributes of this.model in postRender when I fetch a model in controller and pass it to view, but when I fetch a collection in controller and pass that collection to view, I can see the rendered results on page, but this.collection seems to be empty in client side code. (it is not empty in server side code though) To summarize this issue, it looks like this.collection is an empty collection in client side code when initial page render is on server side. Don't you have the same issue @mikepuerto @bigethan ? And if not, what is the version you are using? |
Don't you have the same issue? @saponifi3d and @sarchila, you might have some ideas about this one maybe? |
Try passing the model_name into the view helper as well. Is the model a {{ view 'listing/list-single' model=this model_name='Listing' }} |
Well, it turns out that problem is not about the templates or the loop. I can summarize it as: |
Tried to reproduce this, but I am not seeing the symptoms that you describe here. For reference, though, I am using the newest version of Rendr: It might be that this is fixed by the newer version, or that I am not able to reproduce the issue accurately. |
when I ran into this issue here #390 - I ended up having to go with a different approach being that the amount of help here is scarce. Can't even get @spikebrehm to join any conversation anymore. I've gotta be honest, if there were another, more stable framework... I'd switch in a heartbeat instead of putting all the tim and energy into making changes to the code that they will likely not except a pull request for anyway... -mike (frustrated). |
@sarchila I still have the same issue at that version. @mikepuerto Although I think they would accept a PR which fixes this issue, I feel exactly the same about a more stable framework (which is non-existent AFAIK at the moment). |
i think the I made a extra note: let me know what are some of the biggest bugs you guys are running into, and i'm going to start devoting more of my time to fixing those bugs and updating the documentation of rendr. hopefully this will be getting a lot more stable quickly! |
@demircancelebi - i'm working on a PR to rendr-handlebars to add the forEach helper I wrote. Are there any additional helpers you think might be good to have for everyone? |
Hey, |
interesting that it works in Which is something i noticed in my last commit to Rendr. For some reason it's never actually doing the creation of a I'll take a gander at the code and see if i can't reproduce / fix this bug for ya! (if nothing else, i'll fix it so it will always at least return a collection). |
@demircancelebi I thought the way @por framed this issue (#350) was super helpful because he demonstrated how to reproduce the issue on the If you have some time, would you be able to give a couple of steps on how to reproduce this on that sample app, for instance? I've been trying with no luck to reproduce this issue (been trying with a view and a subview that had a collection passed in). |
Ok, I will do that in the next 24 hours :) |
Has anything been done on this? I have the same issue where models generated on the server are not bound to their view on the client side. The {
"_id": "01234567",
"title" : "My Model",
"elements": {
"12abc213": { "paramA" : "xxxx", "paramB" : "xxxx", "modelToUse" : "modelA" },
"798xzv78": { "paramA" : "xxxx", "paramB" : "xxxx", "modelToUse" : "modelB" }
} now in the
however on the client side, these models are not found in the ---EDIT ---EDIT 2 |
@demircancelebi @azriel46d and @mikepuerto do you have the idAttribute set to _id on the model? if so you should only need to do My guess is that it just needs to be able to grab the instance from the store or rebuild it with the constructor, and those two things are requirements for doing that. |
Is there a solution for this issue? The conversation has died, but the problem remains. I'm running into the same issue. edit: Turns out that i was overriding the parse function on the collection instead of using the jsonKey. Now the collection is parsed without any problem. |
It looks like this bug isn't a rendr bug at all. In my case it was poor coding on my end. Maybe it is time to close this with the note to check what code is overridden in. |
Hi,
I am developing an app with rendr and I am showing some search results in my list.hbs page. It looks like this:
and let's say my listing/list-single.hbs page looks like this:
in the list-single.js file, I cannot access this.model in client side code if the initial page render is on server. I mean, I can access it in getTemplateData function, but cannot access it in postRender. I can also access this.model if the page is rendered on client, so I think something is broken here.
The text was updated successfully, but these errors were encountered: