I currently have a <ul> in my navigation area which holds a <%= render :partial => "sessions/manager" %> which basically calls another partial which depending on the users login status renders either a login form or a welcome statement.
My login section is powered by ajx and so refreshes automaticlly. Here’s the code im using.
login.js
$(document).ready(function() {
$('form#sign_in').bind('ajax:success', function(e, data, status, xhr) {
console.log(data);
if(data.success) {
$('.user_nav').html(data.content);
} else {
$('.user_nav').prepend(data.errors.join('<br />'));
}
});
});
Now I want another div on my page containing various links to either hide or show depending on the users logged in status.
Currently my code is this.
<% if(signed_in?) %>
<li><%= link_to "Clients", "/clients" %></li>
<li><%= link_to "Jobs", "/jobs" %></li>
<% else %>
<% end %>
However, this doesn’t work how id like. The links don’t show at first which is cool BUT the links don’t show again when im signed in… unless I do a full page refresh.
How can I ajax-ify this section?
use CSS’s Visibility property instead, that’s less secure, because anyone can see Links in source code, but will works smoothly.
and if in JSP, try reloading page through that code, inside that if, that will look like sign in, is in progress and meanwhile your page will be refreshed.