- This topic has 2 replies, 2 voices, and was last updated 1 year, 5 months ago by .
-
Topic
-
After updating our Meta Box plugins to the latest versions (Meta Box v5.1.2 and Meta Box Group v1.3.4) my Meta Box groups are suddenly breaking and throwing the error
Uncaught TypeError: Cannot read property 'type' of undefined
.Digging into the code it appears that the
group.toggle.updateTitle
function in thegroup.js
file is looking for the group title element as a direct descendant (the selector is"> .rwmb-group-title, > .rwmb-input > .rwmb-group-title"
) but the group title element is nested under the.rwmb-group-title-wrapper
element so it is not a direct descendant. The code assumes it finds the group title element successfully, tries to get the options from thedata-options
attribute, and then references the option’s title field which is undefined since it didn’t actually find the group title element ordata-options
attribute.Below is an excerpt of the code I’m looking at in the
group.js
file. The$title
variable has a length of zero (no elements found) so therefore theoptions
variable is undefined, which causes the conditional statement ofif ( 'text' === options.type )
to fail.Is this a known bug and if so is there a work-around or fix? We haven’t customized anything so I don’t think this is an issue with just our implementation.
/** * Update group title. * * @param index Group clone index. * @param element Group element. */ group.toggle.updateTitle = function ( index, element ) { var $group = $( element ), $title = $group.find( '> .rwmb-group-title, > .rwmb-input > .rwmb-group-title' ), options = $title.data( 'options' ), content; if ( 'text' === options.type ) { content = options.content.replace( '{#}', index ); } if ( 'field' === options.type ) { var fieldId = $title.data( 'options' ).field, $field = $group.find( ':input[name*="[' + fieldId + ']"]' );
- You must be logged in to reply to this topic.