It would be nice, if the JS could be somehow configured to not transform all .select-or-other fields found. E.g. if someone would want to style it differently without the JS hide/show. (We are using select-or-other in webforms)

Attached is a (minimal, and maybe not suited for all use cases) patch which provides this functionality by:

- rendering the $element['#attributes']['class'] array into the <div class="select-or-other">-wrapper
- in the JS excluding select-or-other-elements from the binding of events if they have the class .select-or-other-disabled-js

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alex-mo’s picture

legolasbo’s picture

Version: 7.x-2.20 » 7.x-3.x-dev

New features will be developed against the 7.x-3.x branch

rodrigoaguilera’s picture

You still have to add some css class and the js is still loaded.

Here's a patch that adds a hook_select_or_other_process_alter the same way that the date module does (eg. http://www.drupalcontrib.org/api/drupal/contributions!date!date.api.php/...)

so you can implement that hook to remove the #attached js.

Status: Needs review » Needs work

The last submitted patch, 3: 2343535-provide-opt-out-possibility-for-JS-hide-show-3.patch, failed testing.

rodrigoaguilera’s picture

Status: Needs work » Needs review
FileSize
406 bytes

That patch was for 2.x.
Here's the one for 3.x.

I didn't found a better way to remove that js.

legolasbo’s picture

@rodrigoaquilera,

If you want to remove JS you can just use core's hook_js_alter().

rodrigoaguilera’s picture

I ended up using the hook on the patch for more stuff since some manipulation of the $element are not available in other hooks.
Also allows you to configure it per element but not if there's two select_or_other elements on the page since js will get included.

legolasbo’s picture

@rodrigoaguilera,

Your request is actually to add a new hook to the module, and while that's in some ways relevant to this issue, should be in it's own feature request. If you could open a new issue for your feature request and state a valid use case for implementing the hook I will consider committing it.

rodrigoaguilera’s picture

Created issue: #2557833: Add new hook_select_or_other_process_alter

Now this can continue with the path that allow to have several select_or_other widgets and disable the js only in some.

legolasbo’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update

It is unclear to me what the goal of this issue is. Please provide a clear issue summary explaining your use case.

legolasbo’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Closing this since there hasn't been an update in over 6 months.

legolasbo’s picture

Closing this since there hasn't been an update in over 6 months.