通过刺激控制器重置文件字段
我有一种通过刺激控制器提交的表格。
#form.html.haml
= form_with url: my_url, multipart: true, data: { turbo_frame: 'document_table_content', turbo_action: 'advanced' } do |f|
= f.file_field 'documents[files]', multiple: true, direct_upload: true, data: { 'dropzone-target' => 'input' }
#dropzone_controller.js
Rails.fire(this.form, "submit");
这起作用,我想在提交重置file_field后另外,我可以通过this.inputtarget
,但是我不知道如何从此表单字段。
I have a form which is submitted through stimulus controller.
#form.html.haml
= form_with url: my_url, multipart: true, data: { turbo_frame: 'document_table_content', turbo_action: 'advanced' } do |f|
= f.file_field 'documents[files]', multiple: true, direct_upload: true, data: { 'dropzone-target' => 'input' }
#dropzone_controller.js
Rails.fire(this.form, "submit");
This works, I want additionally after submit to reset the file_field, I have the target through this.inputTarget
but I don't know how to remove all files from this form field.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说似乎总是很奇怪,但是要实现文件输入的重置您必须重置表格!
It has always seemed strange to me, but to achieve the reset of the file input you have to reset the form!