fayrehouse-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2014-Mar-25 12:00 UTC
Bootstrap Navbar, with options updating a yield in the same view?
So after a couple of days of trawling various forums, tutorials etc - I'm
still no closer to doing what is seemingly something straightforward -
namely, have links on a Navbar populate a named yield with the contents of
a partial. I'm probably missing something fundamental, but hey! I've
asked
this before, but I don't think I worded the question too well, so hopefully
this time I'll do better!
My view as it stands is as follows:
<!DOCTYPE html>> <html lang="en">
> <head>
> <meta charset="utf-8">
> <meta http-equiv="X-UA-Compatible"
content="IE=edge">
> <meta name="viewport" content="width=device-width,
initial-scale=1">
> <meta name="description" content="">
> <meta name="author" content="">
> <link rel="shortcut icon"
href="../../assets/ico/favicon.ico">
> <title>Software Dev Tools Web UI</title>
> </head>
> <div class="container">
> <!-- Static navbar -->
> <div class="navbar navbar-default"
role="navigation">
> <div class="container-fluid">
> <div class="navbar-header">
> <button type="button"
class="navbar-toggle"
> data-toggle="collapse"
data-target=".navbar-collapse">
> </button>
> <a class="navbar-brand"
href="#">MARS Web UI</a>
> </div>
> <div class="navbar-collapse collapse">
> <ul class="nav navbar-nav">
> <<SNIP>>
> </ul>
> <ul class="nav navbar-nav navbar-right">
> <li class="active"><a
href="./">Logout</a></li>
> </ul>
> </div><!--/.nav-collapse -->
> </div><!--/.container-fluid -->
> </div>
> </div>
> <body>
> <div class="container">
> <%= yield :mainbody %>
> </div>
> </body>
>
>
> <script>
> $(".nav li").on("click", function() {
> $(".nav li").removeClass("active");
> $(this).addClass("active");
> });
> </script>
> </html>
>
>
In the <<SNIP>> above, I have tried a couple of ideas. Firstly:
>
> <li><a href="<%= content_for :mainbody do; render
> 'authentication/perforce'; end
%>">P4</a></li>
> <li><a href="<%= content_for :mainbody do; render
> 'authentication/p4_output'; end %>">P4
Output</a></li>
This simply rendered both "perforce" and "p4_output"
partials one below the
other, and clicking the navbar options had no effect.
So then I figured maybe something more like this was required:
>
> <li class="active"><%= link_to "Perforce",
{:action => 'renderp4'},
> :remote => true %></li>
> <li class="active"><%= link_to "Perforce",
{:action => 'renderp4_output'},
> :remote => true %></li>
>
But at this point I came to a grinding halt, not knowing how what would be
needed in my "renderp4" and "renderp4_output" actions so as
to return HTML
to my mainbody yield - if it is even possible?!?
Hopefully what I am trying to achieve is obvious - while I appreciate and
acknowledge I am probably rather wide of the mark with my solution
currently, any guidance would be appreciated. As I say, I've hunted around,
but just hit a brick wall!
Thanks :)
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/e7dd807e-7aff-40b1-a12e-9779427e0fca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.