I have my jQuery UI Tabs working right now but need help implementing the Ajax side. What I need help with is getting #tab-2 to show information (@user.messages) from the MessagesController in a layout that exists as a partial in the MessagesController.
My application.js:
$(function() {
$( "#tabs" ).tabs({
ajaxOptions: {
error: function( xhr, status, index, anchor ) {
$( anchor.hash ).html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo." );
}
}
});
});
My profile show.html.erb:
<div id="tabs">
<ul id="infoContainer">
<li><a href="#tabs-1">About</a></li>
<li><%= link_to "Messages", "messages/profile_messages", :remote => true %></li>
</ul>
<div id="tabs-1">
</div><!-- end profile-about -->
</div>
My _profile_messages partial in MessagesController:
<div id="tabs-2">
<% for 'message' in @user.messages %>
<div class="message">
</div>
<% end %>
</div>
Here is the HTML output of the jQuery UI Tabs:
<div id="tabs">
<ul id="infoContainer">
<li><a href="#tabs-1">About</a></li>
<li><a href="messages/profile_messages" data-remote="true">Messages</a></li>
</ul>
<div id="tabs-1">
Here are the tabs as seen in Firebug:
<div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
<ul id="infoContainer" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tabs-1">About</a></li>
<li class="ui-state-default ui-corner-top"><a href="#ui-tabs-1" data-remote="true">Messages</a></li>
</ul>
<div id="tabs-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
</div>
</div>
The fact that Firebug shows the second link as #ui-tabs-1 seems odd to me. Then when I click the "Messages" link to load the @user.messages, Firebug shows an error Failed to load resource: the server responded with a status of 404 (Not Found) - :3000/profiles/messages/profile_messages.