codeplant/simple-navigation

Render breadcrumbs for post requests

blelump opened this issue · 4 comments

Hi!

I wonder how you deal with rendering breadcrumbs nav and an invalid form? In particular, for some reason validation returned with form errors and the form have been re–rendered from within POST request.

I'm seeing breadcrumbs nav uses selected? method, which in case of Rails, internally uses current_page?from UrlHelper. It implies, however, that current_page? will always return false, because of this statement and hence breadcrumbs nav will not be rendered at all.

Am I missing something here?

andi commented

Are you referring to the fact that URL changes after failing validation? (i.e. it will become the same URL as the index action)...

If yes, you might check out this quite old thread #49 and scroll to the very bottom for a working solution...

@andi ,

thanks for your response. The uri path doesn't change, it stays as it was while rendering the form first time. My point here is that current_page? always returns false if the request is not GET or HEAD.

andi commented

if you rely on autohighlight (without configuring anything regarding highlighting), yes you are right, it will not work for POST or PUT request, for those scenarios you have to use highlights_on

joelw commented

I haven't examined if there are any other implications of doing so in our application, but setting navigation.highlight_on_subpath = true seems to fix URL matching for POST/PUT.