Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails best_in_place jQuery in place editing :activator button not working

I have a partial set up as follows:

<%= best_in_place_if can?(:edit, Artist), @artist, :display_name, type: :input, :activator => "#activator" %>
<a href="#" id="activator">Edit</a>

When I click the Edit link, nothing happens.

If I remove :activator => "#activator" from the best_in_place link, it then allows me to click the text field to start editing as I expect; the only problem is this doesn't work on iPad so I need a separate button to trigger this edit function.

Does anyone know of a workaround for getting the :activator setting working, or have another suggestion (including a different gem) that they know would work for in place editing of fields?

like image 611
bdx Avatar asked Oct 07 '12 08:10

bdx


1 Answers

Are you using the partial to display a list of artists? Perhaps the ID isn't specific enough, so it's getting confused since there's an activator link with id "activator", but there are multiple "activator"s at the same time. Try being more specific with the ID. Something like:

<%= best_in_place_if can?(:edit, Artist), @artist, :display_name, type: :input, :activator => "#activator-#{@artist.id}" %>
<a href="#" id="activator-#{@artist.id}">Edit</a>
like image 88
kindofgreat Avatar answered Oct 15 '22 00:10

kindofgreat