我正在寻找一种方法来进行更复杂的确认,即我现在使用的那个看起来像这样:
<%= 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
有什么线索吗?