From b868d5485116348ff462bf9599a50a93f9e330b8 Mon Sep 17 00:00:00 2001 From: Dario Kampkaspar Date: Tue, 6 Nov 2018 10:41:31 +0100 Subject: [PATCH] change option loading also move select2 (cf. 9c3c445) Cf. #3 --- form.js | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/form.js b/form.js index 487f2bd..7339781 100644 --- a/form.js +++ b/form.js @@ -1,32 +1,12 @@ -var conf = []; -$.getJSON('config.json', function(data) { - conf.push(data); +var conf =[]; +$.getJSON('config.json', function (data) { + conf = data.data; }); -$('#form_people').select2({ - minimumInputLength: 2, - escapeMarkup: function(markup) { - return markup; - }, - templateResult: function(data) { - return data.text; - }, - templateSelection: function(data) { - return data.text; - }, - ajax: { - url: function() { return conf.server + $('#type').val() + '/' }, - dataType: 'json', - processResults: function (data) { - return { results: process(data) }; - } - } -}); - -$('body').on('submit', 'form#person-form', function(event) { +$('body').on('submit', 'form#person-form', function (event) { event.stopPropagation(); event.preventDefault(); var link = $('select#form_people').val(); - console.log( link ); - insertLink ( link ); + console.log(link); + insertLink (link); }); \ No newline at end of file