Home › Forums › Bug Reports › Javascript error when reordering in Post Object Repeater › Reply To: Javascript error when reordering in Post Object Repeater
I’ve been reported with same issue. We are also using Yoast SEO, but disabling did not help.
So I decided to update acf-input.js code… I replaced this original code:
// sortable
$ul.sortable({
stop: function( e ) {
// loop
$ul.find('.select2-selection__choice').each(function() {
// vars
var $option = $( $(this).data('data').element );
// detach and re-append to end
$option.detach().appendTo( $select );
});
// trigger change on input (JS error if trigger on select)
$select.trigger('change');
}
});
with this code:
// sortable
$ul.sortable({
stop: function( e ) {
// get select2 selection
let data = $select.select2('data');
// loop
$ul.find('.select2-selection__choice').each(function() {
// get current element from data
let data_element = data.filter(item => item.text === $(this).attr('title'));
// vars
var $option = $( data_element[0].element );
// detach and re-append to end
$option.detach().appendTo( $select );
});
// trigger change on input (JS error if trigger on select)
$select.trigger('change');
}
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.