Ruby on Rails Wednesday, October 2, 2013

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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.

No comments:

Post a Comment