fix error when adding customfield choice

This commit is contained in:
2018-05-16 21:52:36 +02:00
parent a43dc3733f
commit cacf6d0f3a
3 changed files with 9 additions and 22 deletions

View File

@@ -52,9 +52,9 @@
{# we use javascrit to add an additional element. All functions are personnalized with the id ( = form.vars.id) #}
<script type="text/javascript">
function addElementInDiv(div_id) {
var div = $('#' + div_id);
var prototype = div.data('prototype');
var index = div.data('index');
var div = $('#' + div_id);console.log(div);
var prototype = div.data('prototype');console.log(prototype);
var index = div.data('index');console.log(index);
var add_element_link = $('#' + div_id + '_add_element_link');
var new_fields = prototype.replace(/__name__label__/g, index);
var new_fields = prototype.replace(/__name__/g, index);
@@ -68,7 +68,8 @@
var add_element_link = $('<a id="' + div_id + '_add_element_link"" href="#" class="sc-button bt-submit">{{ 'Add an element'|trans }}</a>');
var div = $('#' + div_id);
div.append(add_element_link);
div.data('index', div.find(':input').length / 5);
div.data('index', div.find('td').length);
console.log(div.data('index'));
add_element_link.on('click', function (e) {
e.preventDefault();