js_options causing error
Support › MB Frontend Submission › js_options causing error
- This topic has 4 replies, 2 voices, and was last updated 11 months, 1 week ago by
Peter.
-
AuthorPosts
-
November 14, 2024 at 5:05 PM #46931
Yasmine
ParticipantHello,
I have recently got a problem with a post (cpt) field not loading the post options .
I have done some testing and have found it was this:
'js_options' => [ 'minimumInputLength' => 2, ]It used to work but now no longer works. Can you confirm if you see the issue too?
November 14, 2024 at 10:19 PM #46935Peter
ModeratorHello Yasmine,
What is the field type that you are using?
November 18, 2024 at 3:07 AM #46948Yasmine
ParticipantOk - but it did used to work! The AJAX has also stopped working too - also works on my other select_advanced fields, just not the post.
Here is an example:
$field = [ 'name' => __('Organisation', 'your-text-domain'), 'id' => 'select_an_org', 'type' => 'post', 'post_type' => ['organisation'], 'field_type' => 'select_advanced', // 'placeholder' => $placeholder, // 'aria-label' => __( 'Select '.$orglabel, 'your-text-domain' ), /* 'query_args' => [ 'post_status' => 'publish', // 'posts_per_page' => 5, 'tax_query' => [ [ 'taxonomy' => 'institution-category', 'field' => 'term_id', 'terms' => $filterterms, ], ], ],*/ 'ajax' => true, // 'clone' => true, // 'max_clone' => 4, ];I disabled plugins and have tested without any of the commented out extras and still not working
November 18, 2024 at 3:14 AM #46949Yasmine
ParticipantAnd in my message before, I was talking about
'js_options' => [ 'minimumInputLength' => 1, ],stopping all the posts from loading entirely but only when
'type' => 'post',. Otherwise on other select_advanced fields it worksNovember 19, 2024 at 10:44 PM #46968Peter
ModeratorHello,
If you use the field
postand field type settingselect_advanced, no need to enable ajax in your code because it is enabled by default. Please follow the documentation https://docs.metabox.io/fields/post/#ajax-loadRegarding the setting
js_options, I recheck this and see that it works properly on my end with any post types. Maybe the JS code is affected by a third-party plugin or a custom code on your site. You can try to deactivate all plugins except Meta Box, MB extension plugins, switch to a WordPress theme and check the issue again. -
AuthorPosts
- You must be logged in to reply to this topic.