fromthepage
fromthepage copied to clipboard
subject subcategory creation dialog doesn't close
When you create a subject sub category, the dialog doesn't close even though the sub category is created.
https://www.screencast.com/t/BfCRbPMBE
I've been investigating this for a bit but can't seem to totally fix it. Here's what I've found:
- Adding a new category does change the URL so that the anchor is for the newly added category.
- Refreshing the page after adding a new category gives the behavior expected when clicking the "Create Category" button -- the dialog/litebox closes, the "Category has been created" alert is displayed, and the new category is shown on the page.
- So, the problem is that the page doesn't refresh after adding a new category?
- The "faulty" redirect is here: https://github.com/benwbrum/fromthepage/blob/ce2ac417340da98b3047916915954ed51dd87919/app/controllers/category_controller.rb#L36-L38
-
Here's a similar issue. Using the proposed solutions -- either adding
:data => {:no_turbolink => true}
ormethod: :get
to theajax_redirect_to
gives some hope of fixing the problem, but doesn't actually. Here's what happens:- The first time you add a new category (you just went to the subjects page and your url is something like
http://localhost:3000/sylviedd/best-collection/subjects
orhttp://localhost:3000/.../subjects#category-2852
), adding a new category works as expected! the litebox closes, the alert shows, and the new category is shown. - After you add a new category (your url will be something like
http://localhost:3000/.../subjects?method=get#category-2866
), if you try to add another category, you get the same broken functionality as present in this issue. You can still reload the page for correct functionality. - If you remove the
?method=get
bit of the url, adding a new category works correctly again.- Is there a way to do this automatically? (Is it good practice?)
- The first time you add a new category (you just went to the subjects page and your url is something like
- This piece of JavaScript might be related to this issue as well:
https://github.com/benwbrum/fromthepage/blob/ce2ac417340da98b3047916915954ed51dd87919/app/views/article/list.html.slim#L82-L94
I tried adding a
location.reload();
here, but it just made the page keep reloading forever.
Why do we have method=get
on the URL? Can you do a git blame on the code that generates that and track down the commit/issue where it was added? I'd be very happy with us using a POST and updating the routes, if that fixes the problem. (It's best practice for a write, anyway.)
The method=get
is from adding method: :get
to this line:
https://github.com/benwbrum/fromthepage/blob/ce2ac417340da98b3047916915954ed51dd87919/app/controllers/category_controller.rb#L38
I added it for testing, because it was suggested in that stack overflow post. That's what halfway fixed the issue.
@benwbrum As per Our Previous discussions this issue is fixed so I think this need to be closed
Great!