简体   繁体   English

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

[英]How to embed javascript confirmation box in Slim href?

I want the following action 我要采取以下行动

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

to be done only after I agree to it on a confirmation box. 仅在我在确认框上同意后才能进行。 I want to embed in this href the javascript code: 我想在此href中嵌入javascript代码:

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

I am using Slim. 我正在使用Slim。 Thanks. 谢谢。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM