Here's the code
https://gist.github.com/dasibre/6786245

*new.js.erb file has the following js code*
 
$('a.pinbutton').on('click', function() {
    $(this).parent().append('<%= escape_javascript(render("select")) %>')
});
 
*here's the player index with the new link*
<%= link_to "Pin", {controller: "pinboard_players", action: "new", id: player}, 
remote: true, class: "pinbutton", id: "#{player.id}"  %>
 
*controller new action action:*
def new
     session[:player] = params[:id]
      @pinboard_player = PinboardPlayer.new(player_id: params[:id]) 
      @current_user_pinboards = get_user_pinboards
      respond_to do |format|
        format.html
        format.js
      end
  end

When I click on the button, to display the select form, it takes two clicks for 
the javascript to work.

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/8faeeb6f-d5c1-4c36-924a-4e59a0397279%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to