gpt4 book ai didi

elixir - 删除链接不起作用 Phoenix

转载 作者:行者123 更新时间:2023-12-04 00:49:38 25 4
gpt4 key购买 nike

我使用 Phoenix 的内置 gen.HTML 来生成一个简单的 View ,但它不起作用

<%= link "Delete", to: event_path(@conn, :delete, event), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %>

在页面上,它看起来像它假设的那样,但它只是将 # 附加到地址

生成的结构:
<form action="/event/1" class="link" method="post">
<input name="_method" type="hidden" value="delete">
<input name="_csrf_token" type="hidden" value="BwUSGQcDO1MwPzw0HBgqLnshHn8HNgAAnCTjuMt0viFshobX4XM/dQ==">
<a class="btn btn-danger btn-xs" data-confirm="Are you sure?" data-submit="parent" href="#">Delete</a>
</form>

我是否缺少某种 js 导入?
我也可以通过浏览器下载这个:
//This is being downloaded as phoenix_html.js
// Although ^=parent is not technically correct,
// we need to use it in order to get IE8 support.
var elements = document.querySelectorAll('[data-submit^=parent]')
var len = elements.length

for (var i=0; i<len; ++i) {
elements[i].addEventListener('click', function(event){
var message = this.getAttribute("data-confirm")
if(message === null || confirm(message)){
this.parentNode.submit()
};
event.preventDefault()
return false
}, false)
}

最佳答案

编辑:这恰好是已知问题。这是修复:

In brunch-config.js
autoRequire: {
"js\\app.js": ["web/static/js/app"]
}

Source

关于elixir - 删除链接不起作用 Phoenix ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34272706/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com