From: Steve Sutton Date: Wed, 18 Sep 2019 17:09:15 +0000 (-0400) Subject: Update js for shortcodeBuilder to check for dupes in members. X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Ffeature%2FshortcodeBuilder;p=WP-Plugins%2Fglm-member-db.git Update js for shortcodeBuilder to check for dupes in members. Check the members for a duplicate before adding them. --- diff --git a/js/shortcodeBuilder.js b/js/shortcodeBuilder.js index 1f6b289e..e3febc8f 100644 --- a/js/shortcodeBuilder.js +++ b/js/shortcodeBuilder.js @@ -81,12 +81,6 @@ jQuery(function ($) { } setupAttributes(); var cache = {}; - var memberNames = [ - { label: 'Steve', value: 1 }, - { label: 'George', value: 2 }, - { label: 'Dave', value: 3 }, - { label: 'Banner', value: 4 } - ]; $('#shortcode-members').autocomplete({ minLength: 2, source: function( request, response ){ @@ -106,8 +100,10 @@ jQuery(function ($) { var type = 'members'; let record = {id: ui.item.value, name: ui.item.label, type: 'members'}; $('#shortcode-members').val(''); - shortcodeAttributes['members'].list.push(record); - updateShortcode({list: shortcodeAttributes[type].list, type: type, isList: shortcodeAttributes[type].isList}); + if ( !checkDuplicates( record, shortcodeAttributes[type].list ) ) { + shortcodeAttributes['members'].list.push(record); + updateShortcode({list: shortcodeAttributes[type].list, type: type, isList: shortcodeAttributes[type].isList}); + } }, close: function( event, ui ) { $('#shortcode-members').val('');