Re: Render Django Form with Ajax Response
For anyone who is curious how to make this work in the future (I always appreciate people sharing) I got lucky this time. There were absolutely no signals to what the issues is so I started guessing. It ended up being that because of the nature of the comment form being rendered with ajax it did not have access to the js files that are loaded into your general HTTP request html so by adding the js files it needed directly into the forms.html file for django comments I was able to have the comments form not fail its ajax request and the comment was successfully posted. Sometimes it pays to be lucky because I was scouring the internet for any tips at all and there was honestly really nothing that helped. Sometimes people had issues with the id of the submission button but for me it was something about how the js files were loaded into the template that was used to make the form. Now it has what it needs if it is ever rendered with ajax and not your normal flow. Really glad it panned out and I got lucky on this one. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7aa59d5f-8138-4053-b79f-8ecd0aa30a09%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Render Django Form with Ajax Response
So like expected i made the post form work by only rendering it once and then using hidden fields to make the form work for my 3 feeds so posted would be created properly but i am still not sure if conceptually i understand why when the comment form is rendered with ajax for a that it doesnt work. Maybe someone has an idea. I refactored django comments to work with ajax but we will see. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/35138364-1e8c-4b04-8467-cd673906b1e4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Render Django Form with Ajax Response
I'm almost positive there is some way to achieve this though. For example, in a facebook group for example when you scroll it loads a new set of posts and those posts are loaded with ajax and those posts have a comment form that was again obviously rendered with ajax. My situation is the same situation. On an ajax response I render the new posts and the comment form under it however it does not work. And I know it works on a regular HTTP GET with an ajax request so what changes that I don't see between returing this form with ajax that uses the same infastructure? I have no idea I thought and assumed that the same code would execute the same way no matter how the form got there to begin with, it stumps me. I am willing to share any code if necessary but to me that isnt necessary as this is a high level issue. Now if I need to use something like the django stream framework or pagination or something feel free to tell me I'm doing it wrong because I have exhausted all my ideas. But even if i rendered the stream with those structures off hand I would still think I would have the same issue because well there would be a comment form rendered via ajax. Honestly come to think of it it doesnt matter that I have 3 streams rendered with ajax because again facebook groups when scrolling load the new items with ajax so again that means the comment form was loaded with that. Im aiming for that same functionality in some respects. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/072b2d35-264f-4397-9378-c9bdd44f719b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Render Django Form with Ajax Response
So what I'm trying to build is pretty complicated and I would like to see if this is even achievable. What I'm building has multiple feeds but on the same view. So on the initial GET request it loads the default feed and then say the user wants to load another one of the feeds of posts with comments they can click that name and it uses ajax to load the new posts and comments on the bottom. Which obviously must render the comment form so that if someone wanted to add another comment they could. The issue whenever I render the posts and comments underneath them in this fashion the backend that creates comments does not see the Ajax request I am expecting it to. Basically, when it is a regular GET and it returns say the default stream of posts and comments everything is just dandy. But when I render the post form, post stream, and comments under those, the forms that worked just a minute ago do no work having been returned from a render to string call on a template that is dumped via an .html() call in a ajax response. Is this simply not achievable on the web? Or am I just ignorant to a solution to design this? Before my intention was to have 3 different views and urls and that could have probably worked given what I feel I know now but to me this solution I am working on is what I want. It is very nice to me to have one page for my app that has 3 feeds under that umbrella. It's just to make it all work and the page not refresh that requires ajax to load the relevant streams requested and that all works but so far I simply cannot make the form submit properly. The form shows up based on the template that is rendered but it is a no go when it comes to form submission it appears. Thanks for your insights. JJ Zolper -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d730b3b7-766f-4735-ba12-e082c09d4df8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.