Problem/Motivation

We want to enable Chosen only in the administration theme of our project. We tried to use the selectors setting, but it doesn't work. Either chosen apply on all select or the functionality breaks when we use AJAX in views.

This issue / feature is exactly the opposite of this one: Disable chosen on admin pages

Proposed resolution

The idea is to add a checkbox in the settings to apply chosen in the admin theme only. These changes will be applied by creating a patch based on the patch #32 in the issue : https://www.drupal.org/node/2089987.

Remaining tasks

Patch will be attached.

User interface changes

A checkbox to be added in the module settings to apply chosen only in the admin theme.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sseguin’s picture

sseguin’s picture

sseguin’s picture

sseguin’s picture

villette’s picture

I've updated the patch in #3 to include three options:

  • Include Chosen on every page
  • Include Chosen only on admin pages
  • Include Chosen only on front end pages
JeroenT’s picture

Status: Active » Needs review
brockfanning’s picture

The patch works as it is intended, but unfortunately doesn't catch my use-case, which is the ctools modals that pop up when using Panels' in-place editor. This isn't surprising, since the page that the modals display on is neither administrative nor ajax.

In case it helps, the trick in using the selectors setting may be to figure out what the "context" variable is in the chosen.js. For example I wanted to get Chosen working in panels IPE modals. First I tried:

body.panels-ipe select:visible

But that didn't work. The reason is the the body element is outside the "context" variable in chosen.js. So I tried this:

.ctools-modal-content select:visible

This works because .ctools-modal-content is inside the "context" variable in chosen.js.

brockfanning’s picture

To be clear though, I tested the patch and it does work. I only included the info about the selectors setting on the off chance that it may help with the original problem.

lpeabody’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed and tested by brockfanning.

nagy.balint’s picture

Going to review this soon.

mr.york’s picture

Tested and reviewed ant reroll last patch.

  • nagy.balint committed b1897fa on 7.x-2.x authored by villette
    Issue #2534756 by sseguin, villette, mr.york, brockfanning: Enable...
nagy.balint’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Committed.

mr.york’s picture

Version: 7.x-2.x-dev » 8.x-2.x-dev
mr.york’s picture

Status: Patch (to be ported) » Needs review
FileSize
4.21 KB

Attached d8 port.

  • nagy.balint committed 08891c9 on 8.x-2.x authored by mr.york
    Issue #2534756 by sseguin, mr.york, villette: Enable Chosen on admin...
nagy.balint’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Needs work

The last submitted patch, 15: enable_chosen_on_admin-2534756-15.patch, failed testing.

JeroenT’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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