Skip to content

Commit

Permalink
Merge branch 'trunk' of https://github.com/amans2k/CMB2 into amans2k-…
Browse files Browse the repository at this point in the history
…trunk
  • Loading branch information
jtsternberg committed Jan 18, 2019
2 parents d130295 + a88d18f commit 4777697
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion includes/CMB2.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ public function render_group_row( $field_group ) {
$confirm_deletion = ! empty( $confirm_deletion ) ? $confirm_deletion : '';

echo '
<div class="postbox cmb-row cmb-repeatable-grouping', $closed_class, '" data-iterator="', $field_group->index, '">';
<div id="cmb-group', $field_group->id(), '-', $field_group->index, '" class="postbox cmb-row cmb-repeatable-grouping', $closed_class, '" data-iterator="', $field_group->index, '">';

if ( $field_group->args( 'repeatable' ) ) {
echo '<button type="button" data-selector="', $field_group->id(), '_repeat" data-confirm="', esc_attr( $confirm_deletion ), '" class="dashicons-before dashicons-no-alt cmb-remove-group-row" title="', esc_attr( $field_group->options( 'remove_button' ) ), '"></button>';
Expand Down
5 changes: 4 additions & 1 deletion js/cmb2.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,14 @@ window.CMB2 = window.CMB2 || {};

var $table = $id( $this.data('selector') );
var $oldRow = $table.find('.cmb-repeatable-grouping').last();
var $oldRowId = $oldRow.attr('id');
var prevNum = parseInt( $oldRow.data('iterator'), 10 );
cmb.idNumber = parseInt( prevNum, 10 ) + 1;
var $row = $oldRow.clone();
var nodeName = $row.prop('nodeName') || 'div';

$oldRowId = $oldRowId.substring(0, $oldRowId.length - 1);

// Make sure the next number doesn't exist.
while ( $table.find( '.cmb-repeatable-grouping[data-iterator="'+ cmb.idNumber +'"]' ).length > 0 ) {
cmb.idNumber++;
Expand All @@ -664,7 +667,7 @@ window.CMB2 = window.CMB2 || {};
cmb.newRowHousekeeping( $row.data( 'title', $this.data( 'grouptitle' ) ) ).cleanRow( $row, prevNum, true );
$row.find( '.cmb-add-row-button' ).prop( 'disabled', false );

var $newRow = $( '<' + nodeName + ' class="postbox cmb-row cmb-repeatable-grouping" data-iterator="'+ cmb.idNumber +'">'+ $row.html() +'</' + nodeName + '>' );
var $newRow = $( '<' + nodeName + ' id="'+ $oldRowId + cmb.idNumber +'" class="postbox cmb-row cmb-repeatable-grouping" data-iterator="'+ cmb.idNumber +'">'+ $row.html() +'</' + nodeName + '>' );
$oldRow.after( $newRow );

cmb.afterRowInsert( $newRow );
Expand Down

0 comments on commit 4777697

Please sign in to comment.