Skip to content

Commit

Permalink
Fix multi-nested group index incrementing
Browse files Browse the repository at this point in the history
Resolves #48
  • Loading branch information
shadyvb committed Feb 2, 2014
1 parent 92ff144 commit 5222004
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ui/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jQuery(function($){
divTriggers = $('#triggers'), // Trigger Playground
divAlerts = $('#alerts .inside'), // Alerts Playground

iGroup = 0,

btns = {
add_trigger: '.add-trigger',
add_alert: '.add-alert',
Expand Down Expand Up @@ -131,7 +133,7 @@ jQuery(function($){
var $this = $(this),
index = 0,
lastItem = null,
group = divTriggers.find('.group').filter( '[rel=' + $this.data('group') + ']' );
group = divTriggers.find('.group[rel=' + $this.data('group') + ']' );

if ( ( lastItem = divTriggers.find('.trigger').last() ) && lastItem.size() ) {
index = parseInt( lastItem.attr('rel') ) + 1;
Expand All @@ -151,11 +153,10 @@ jQuery(function($){
var $this = $(this),
lastItem = null,
parentGroupIndex = $this.data('group'),
group = divTriggers.find('.group').eq(parentGroupIndex);
group = divTriggers.find('.group[rel=' + $this.data('group') + ']' );

if ( ! groupIndex ) {
if ( ( lastItem = divTriggers.find('.group').last() ) && lastItem.size() ) {
groupIndex = parseInt( lastItem.attr('rel') ) + 1;
}
groupIndex = ++iGroup;
}

group.append( tmpl_group({ index: groupIndex, parent: parentGroupIndex }) );
Expand Down

0 comments on commit 5222004

Please sign in to comment.