Rails best_in_place jQuery in place editing :activator button not working

耗尽温柔 提交于 2019-12-07 05:32:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!