Skip to content

Commit

Permalink
Fix backend of valid option field
Browse files Browse the repository at this point in the history
Signed-off-by: CJ Estavillo <estavillocj43@gmail.com>
  • Loading branch information
cjestavillo committed Apr 12, 2018
1 parent ee4d424 commit dfa9c86
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/Schema/template/_scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,7 @@
$(window).on('keyval-add-click', function(e, trigger) {
var last = $(trigger).parent().find('div.keyval-row:last');

// since this is only activated after clicking the add option
// and there's previous option already
var index = 1;
var index = 0;
if(last.length) {
index = parseInt(last.attr('data-index')) + 1;
}
Expand Down Expand Up @@ -618,31 +616,32 @@
container.find('div.input-input').remove();

if(!container.find('div.input-options').length) {
//compile option field
//compile add option button field
var template = 'fields[{INDEX}][validation][{INDEX}][parameters][{INDEX}]';
var parameters = $('#field-options-template')
.compile({
NAME: template
.replace('{INDEX}', trigger.getModelIndex())
.replace('{INDEX}', container.attr('data-index'))
})
.doon();

trigger.parent().after(parameters);

//compile option field
var index = 0;
var name = template
.replace('{INDEX}', trigger.getModelIndex())
.replace('{INDEX}', index)
.replace('{INDEX}', index);
var index1 = container.attr('data-index');
var row = $('#field-option-row-template')

var option = $('#field-option-row-template')
.compile({
NAME: name,
INDEX: index
})
.doon();
trigger.parent().after(row);

var parameters = $('#field-options-template')
.compile({
NAME: template
.replace('{INDEX}', trigger.getModelIndex())
.replace('{INDEX}', container.attr('data-index'))
})
.doon();

row.after(parameters);
parameters.prepend(option);
}
break;
}
Expand Down

0 comments on commit dfa9c86

Please sign in to comment.