私は次のものを持っていますindex.js.erb
:
$(function () {
var $team = $('#createTeam'),
$user = $('#createUser'),
$userPanel = $('.createUserPanel'),
$teamPanel = $('.createTeamPanel');
$user.click(function(){
$userPanel.append('<%= j render 'form_user' %>').fadeIn('slow');
$(this).fadeOut();
});
$team.click(function(){
$teamPanel.append('<%= j render 'form_team' %>').fadeIn('slow');
$(this).fadeOut();
});
})();
私のこれらのリンクと一緒に行くにはindex.html.erb
:
<%= link_to "+", "#", 'data-action' =>"create",'data-target'=> "team", id: "createTeam", remote: true %>
<%= link_to "+", "#", 'data-action' =>"create",'data-target'=> "user", id: "createUser", remote: true %>
どちらかのリンクを最初にクリックしても何も起こりませんが、2回目と3回目のクリックで両方のフォームが表示されます。リンクをクリックするたびに、ボタンがフェードアウトし、フォームが別のdivに表示されます。
望ましい実装は、いずれかのリンクをクリックするform_*
とが表示され、ボタンがフェードアウトすることです。どうすればこれを達成できますか?