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

Cyclodex’s picture

Status: Active » Needs review
StatusFileSize
new480 bytes

Hey

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

Cyclodex’s picture

Can someone please test this too?
Some feedback would be great before adding this to the code base.

Cyclodex’s picture

Assigned: Unassigned » Cyclodex
jibus’s picture

Hello,

I can't reproduice your problem.

I set a view with ajax auto-submit. Everything works fine.

I set the dev version

dealancer’s picture

Status: Needs review » Reviewed & tested by the community

Patch #1 fixes this problem! Thanks.

Cyclodex’s picture

Thanks for your feedback dealancer!

kalman.hosszu’s picture

Status: Reviewed & tested by the community » Fixed

It's committed in 2.x branch. Thanks

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

badrange’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Assigned: Cyclodex » Unassigned
Issue summary: View changes
Status: Closed (fixed) » Active
StatusFileSize
new496 bytes

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

badrange’s picture

Status: Active » Needs review
Anonymous’s picture

Status: Needs review » Needs work

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

badrange’s picture

Did 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?

Anonymous’s picture

Yeah, 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.

Anonymous’s picture

Status: Needs work » Reviewed & tested by the community
badrange’s picture

Glad 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!

kalman.hosszu’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all, the patch is committed into 7.x-2.x

maximpodorov’s picture

Status: Fixed » Needs work

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

maximpodorov’s picture

Status: Needs work » Needs review
StatusFileSize
new422 bytes

Does this patch (for the current dev) solves the problem also?

Anonymous’s picture

#18 works fine. If this one prevents the extra request then I would favor #18.

badrange’s picture

Status: Needs review » Reviewed & tested by the community

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

kalman.hosszu’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, the patch is committed to 7.x-2.x dev branch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jweirather’s picture

This 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:

Ultimately, this post here lead me to look into the CTOOLs auto-submit JS file, and only by adding '.chosen-search-input' to the filter on line 79 in the key ignore section would the auto submit work properly and ignore the Chosen Multi-Select Search Box.

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.