I have a view that I have set to use AJAX and to autosubmit whenever something is selected in one of the exposed filters on the view. If I use chosen, and select an option by hand, then the view updates normally.
However, if I use Chosen's feature that allows me to search for an option in the list, the view starts updating via AJAX before I can choose an option from the searched results, and then the view basically resets.
I'm wondering if this is something this module could solve, or something that would need to be modified in the Chosen library itself.
Possibly somewhat related: #1270198: How to use Chosen with the References module?.
Comments
Comment #1
Cyclodex commentedHey
Wondering that this issues is that old, and nobody has a solution yet ?...
Had the same issue, the auto submit was run already when typing some chars. But with chosen we want to auto submit the data when a value was selected.
This seems to be a problem in ctools auto-submit.js file, which is also making troubles with the basic auto-completion field, not just chosen!
Check issue over there: #1324238: Not all views exposed forms auto-submit correctly (was: Clean up and improve auto-submit.js0
I added some functionality to the chosen module, to have its own auto submit feature. But later then I found out that the problem is fixed when the chosen.js is loaded after the auto-submit.js! That's it...
So I tried to load it later in the process, and this looks like its fixing the issues !
I attached a patch (my first one) so please test and review it.
[Beep] Cyclodex
Comment #2
Cyclodex commentedCan someone please test this too?
Some feedback would be great before adding this to the code base.
Comment #3
Cyclodex commentedComment #4
jibus commentedHello,
I can't reproduice your problem.
I set a view with ajax auto-submit. Everything works fine.
I set the dev version
Comment #5
dealancer commentedPatch #1 fixes this problem! Thanks.
Comment #6
Cyclodex commentedThanks for your feedback dealancer!
Comment #7
kalman.hosszu commentedIt's committed in 2.x branch. Thanks
Comment #9
badrange commentedThis problem seems to have been reintroduced since it was originally reported. I added the same solution in the attached patch, for the 2.x branch.
I hope it was ok that I highjacked the original bug report.
Comment #10
badrange commentedComment #11
Anonymous (not verified) commentedI have succesfully applied the patch but nothing seems to have changed.
After submitting a view via ajax, the view exposed filters change back to the non-chosen version.
Comment #12
badrange commentedDid you make sure to clear all caches AND shift-refresh the page in your browser so the browser loads all components from the server and not it's own cache?
Comment #13
Anonymous (not verified) commentedYeah, cache is not the problem.
The selector configured in the Chosen config is not applied when refreshing.
I have set: "body.page-admin select:visible" and then chosen is not applied when refreshing after a ajax submit.
When I set it to "select" then the patch does work.
Edit:
I do admit that this a rare circumstance but in this case we only wanted the chosen plugin to work on the admin pages.
Comment #14
Anonymous (not verified) commentedComment #15
badrange commentedGlad you got the patch to work. I don't think it is a rare case to only wish chosen to be addd on the admin pages, though - hope you figure that out too!
Comment #16
kalman.hosszu commentedThanks all, the patch is committed into 7.x-2.x
Comment #17
maximpodorov commentedI think this fix is incorrect, it creates extra request for the JS file which was aggregated before. Maybe manipulating the module weight will be enough.
Comment #18
maximpodorov commentedDoes this patch (for the current dev) solves the problem also?
Comment #19
Anonymous (not verified) commented#18 works fine. If this one prevents the extra request then I would favor #18.
Comment #20
badrange commentedI tested the patch in #18 on my system, and it worked nicely.
Note: The patch applies cleanly to the git revision that already has my earlier patch in it.
Don't try to patch the download.
Comment #21
kalman.hosszu commentedThanks, the patch is committed to 7.x-2.x dev branch.
Comment #23
jweirather commentedThis appears to have come up again?
Where we were using CTools autosubmit and Chosen fields in Views Exposed Filters, and on features we're highly confident were working fine before, very recently we began having users report the behavior described here. That when using the search feature in the Chosen widget, the form began to submit after the text was entered, but before the item was selected from the Chosen list. The effect was a search results reload without anything having been set on the Chosen field.
We were able to reproduce this in both our Dev and Prod environments. The patch did not resolve the issue for us. Ultimately I found the following thread:
https://www.drupal.org/project/better_exposed_filters/issues/3024267#com...
And applied the fix from it:
Which resolved the issue for me. It's a little hacky and I'd love to get to a root cause/solution, but this might help others in the meantime.