【发布时间】:2014-04-15 05:02:06
【问题描述】:
我正在寻找一种方法来更复杂地确认我现在使用的那个看起来像这样:
<%= link_to_remove_association "<i class='icon-remove-sign'></i>".html_safe,
p, :class => 'btn-link remove has-tooltip',
:data => {:original_title => "Delete phone",
:confirm => 'Are you sure you want to delete this phone?'} %>
如果电话条目为空白,我只想避免确认对话框。
我认为在 'cocoon:before-remove' 事件中一定有办法,但我找不到它?
例如,在这样的 Coffesecript 函数中:
$(document).delegate '.phones', 'cocoon:before-remove', (e, item) ->
tel = $(item).find('.tel .form-control')
conf = true
if tel.val().trim() != ''
conf = confirm('Are you sure you want to delete this phone?')
if conf
$(@).data('remove-timeout', 1000)
item.fadeOut('slow')
else
#stop deletion!!
conf
有什么线索吗?
【问题讨论】:
标签: ruby-on-rails ruby coffeescript cocoon-gem