Support

Account

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');
    		            }
    				});