单击标签名称时 Rails best_in_place gem [英] Rails best_in_place gem while clicking on the label name

查看:36
本文介绍了单击标签名称时 Rails best_in_place gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最好的就地宝石 - 这很棒.唯一的问题是我希望用户不仅能够点击最佳就地元素进行编辑,还能够点击标签.假设我有这个最好的元素:

I am using the best in place gem - which is great. Only thing is that I want the user to be able to click not just the best in place element in order to edit it, but also the label. Lets say I have this best in place element:

<b>Open Hours</b>
<%= best_in_place @provider, :open_hours, :type => :select, :collection => Provider::PROVIDERS_HOURS %>

我希望能够单击营业时间"以打开编辑元素.可能吗?

I want to be able to click the Open Hours in order to open the edit element. Is it possible?

谢谢

推荐答案

对于类的单个实例,您可以简单地

For single instance of a class you can simply

<b id='edit-open-hours'>Open Hours</b>
<%= best_in_place @provider, :open_hours, type: :select, collection: Provider::PROVIDERS_HOURS, activator: '#edit-open-hours' %>

如果要使用列表视图执行此操作,则需要使用 ID 使每个 id-identifier 具有唯一性

If you want to do this with a list view you will need to make each id-identifier unique with an ID

<b id='edit-<%= @provider.id %>'>Open Hours</b>
<%= best_in_place @provider, :open_hours, type: :select, collection: Provider::PROVIDERS_HOURS, activator: '#edit-' + @provider.id.to_s %>

这篇关于单击标签名称时 Rails best_in_place gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆