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

chosen.js not initialized when display-if field is toggled #882

Open
dlh01 opened this issue Jan 14, 2025 · 0 comments
Open

chosen.js not initialized when display-if field is toggled #882

dlh01 opened this issue Jan 14, 2025 · 0 comments
Labels
bug Something isn't working javascript Requires understanding JavaScript

Comments

@dlh01
Copy link
Member

dlh01 commented Jan 14, 2025

Description of the bug

When a select field using both type_ahead and display_if is initially hidden, chosen.js isn't initialized when the field is shown.

Steps To Reproduce

Test with this group by saving it with disable_blocks enabled, and you should see that the typeahead UI on disable_block_terms isn't initialized on the next pageload after unchecking disable_blocks:

new Fieldmanager_Group(
	[
		'label'    => 'Ads',
		'children' => [
			'disable_blocks'  => new \Fieldmanager_Checkbox( 'Disable all blocks' ),
			'disable_block_terms' => new Fieldmanager_Select(
				[
					'label'      => 'Disable blocks on these categories',
					'datasource' => new Fieldmanager_Datasource_Term(
						[
							'taxonomy' => 'category',
						],
					),
					'display_if' => [
						'src'   => 'disable_blocks',
						'value' => '0',
					],
					'multiple'   => true,
					'type_ahead' => true,
				],
			),
		],
	]
)

Additional Information

Adding fm_displayif_toggle to this list seems to fix the problem:

$('.fm-wrapper').on("fm_added_element fm_collapsible_toggle fm_activate_tab",".fm-item",function(){

@dlh01 dlh01 added the bug Something isn't working label Jan 14, 2025
@kevinfodness kevinfodness added the javascript Requires understanding JavaScript label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working javascript Requires understanding JavaScript
Projects
None yet
Development

No branches or pull requests

2 participants