meteor-autoform-select2
meteor-autoform-select2 copied to clipboard
Clear all selected when submit error, but not clear when submit success???
I have the problem when I submit form error, it clear all of selected value. But when the submit form success, it not clear selected label (value is empty).
yep, I also have this issue. @thearabbit did you ever get around this?
Oh, How the solution?
I got around by using selectize. Thought it has exactly the same issue, but at least I could reset it "manually".
AutoForm.addHooks(['insertProductForm'], {
onSuccess: function(formType, result) {
$('select')[0].selectize.clear()
}
})
Select2 also should have this functionality, but I just couldn't get $.fn.select2.defaults.reset()
to work.
I tried selectize
, but have any problem withe onchage
order. for example I have 2 selectize
and when I on change the first to change value of the second, it not work on the second.
This worked for me, although it clears all selects.
AutoForm.addHooks(['insertProductForm'], {
onSuccess: function(formType, result) {
$('select').each(function() { //Select2 doesnt clear on its own
$(this).select2('val', '');
});
}
})
Look great, it work fine on success hook.
But I still have problem with onError
(all select2
is clear).
I Haven't had a chance to test the onError case yet.