Ruby on Rails Thursday, October 3, 2013

On 2 October 2013 23:06, dasibre <james.naadjie@gmail.com> wrote:
> 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.

Have a look in development.log to see what is happening when you press
it the first time, then the second.

Colin

--
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/CAL%3D0gLsadi6H-z6iCWg%2B5u2Ncd_jP1XGF%2BYO_%3Dgp4aFwfHbjaA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment