Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear all selected when submit error, but not clear when submit success??? #37

Open
thearabbit opened this issue Jun 6, 2015 · 7 comments

Comments

@thearabbit
Copy link

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).

@KristerV
Copy link

yep, I also have this issue. @thearabbit did you ever get around this?

@thearabbit
Copy link
Author

Oh, How the solution?

@KristerV
Copy link

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.

@thearabbit
Copy link
Author

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.

@drew-y
Copy link

drew-y commented Jul 17, 2015

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', '');
        });
    }
})

@thearabbit
Copy link
Author

Look great, it work fine on success hook.
But I still have problem with onError (all select2 is clear).

@drew-y
Copy link

drew-y commented Jul 18, 2015

I Haven't had a chance to test the onError case yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants