Meteor autoformer add an extra entry

I would like to get the value of an input in AutoForm.hooks
callback. This input is not part of my schema, it determines what template shows after form submission (and some other behind the scenes stuff). I’m creating the input by using plain html in my autoform template.

I tried

insert: function(error, result, template){

which appears to give me the default template html, not the live inputs.

What’s the best way to get the value of this input?


I tried to grab the input value in the after
callback by simply using jQuery and selecting the input. However, the form clears via some method in autoform before the after callback is run, so that was a no-go.

I ended up storing this value globally from inside the before
callback, then checking that value in the after

This still seems like a hacky way to do things – I should be able to grab this value somehow, even if I have to create the input in a ‘special’ way with autoform.

Another issue is that I may have more than one of this form in the DOM at a time, so my solution would not cleanly work in that instance.

To prevent AutoForm from clearing out the inputs upon submission, you can specify resetOnSuccess=false
on the autoform template. You could then grab the value of the desired input in the hooks, and subsequently call AutoForm.resetForm(formId)
to manually clear out the form.

Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » Meteor autoformer add an extra entry

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录