问题
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?
回答1:
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>
来源:https://stackoverflow.com/questions/12767383/rails-best-in-place-jquery-in-place-editing-activator-button-not-working