如何在Slim href中嵌入javascript确认框?

时间:2014-07-17 15:29:58

标签: javascript slim-lang

我想要以下行动

a href= url(:event, :destroy, event: allocation.id, company_id: company.id) title="Delete This Event" ==t 'actions.delete'

只有在我同意确认框后才能完成。我想在这个href中嵌入javascript代码:

'javascript:onClick=window.confirm("Are you SURE you want to Delete this Event?")'

我正在使用Slim。 感谢。

1 个答案:

答案 0 :(得分:0)

如果您正在使用启用了jquery-ujs的rails,就像这样

= link_to t('actions.delete'), url, confirm: 'Are you SURE you want to Delete this Event?'