Sha256: 674a58de18a54542c2ee64d9d46715d3e67454577a58a4299022e12918ecf09e
Contents?: true
Size: 1.92 KB
Versions: 8
Compression:
Stored size: 1.92 KB
Contents
//=require formily/lib/tag-it.min window.formilyRelatedTags = []; $(document).on('ready formily_loaded', function(){ $('.related_value_tag').each(function(_, element){ var self = $(element); var input = self.parent().find('input.related[data-ff-related]'); self.tagit({ fieldName: '', singleFieldNode: input.get(0), showAutocompleteOnFocus: true, singleField: true, singleFieldDelimiter: '.', autocomplete: { delay: 0, minLength: 0, source: function(request, response) { var value = this.element.parent().find('input[type=hidden]').val(); if(value && value.length > 0) { value= value.split('.') } $.ajax({ url: '/formily/inputs/render_related', data: {related_arr: value}, type: 'GET', success: function(data){ window.formilyRelatedTags = []; if (data && data.length > 0) { data.forEach(function(el, _) { window.formilyRelatedTags.push(el.label)}); response(data); } } }); } }, removeConfirmation: true, beforeTagAdded: function(event, ui) { if(ui.tag.hasClass('fake')) { return true; } if (window.formilyRelatedTags.indexOf(ui.tagLabel) < 0) { return false; } }, beforeTagRemoved: function(event, ui) { var tag = ui.tag; var parent = tag.parents('ul:first'); tag = tag.next(); if(tag && tag.hasClass('tagit-choice')) { var label = tag.find('span.tagit-label').text(); $(parent).tagit('removeTagByLabel', label); } } }); }); $(document).on('change', 'input.related[data-ff-related]', function(){ window.InputModel.setTagAttr('data-related', $(this).val()); }); });
Version data entries
8 entries across 8 versions & 1 rubygems