9 lines
		
	
	
		
			1019 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			9 lines
		
	
	
		
			1019 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /*
 | |
|  * Copyright © 2024 Regular Labs - All Rights Reserved
 | |
|  * GNU General Public License version 2 or later
 | |
|  */
 | |
| (function(){'use strict';document.querySelectorAll('rl-field-simple-category').forEach((simplecategory)=>{const fancy_select=simplecategory.querySelector('joomla-field-fancy-select');const select=simplecategory.querySelector('select');const input=simplecategory.querySelector('input.choices__input');if(!fancy_select||!select||!input){return;}
 | |
| const choices=fancy_select.choicesInstance;input.addEventListener('change',(event)=>{choices.clearInput();});input.addEventListener('keyup',(event)=>{if(event.keyCode!==13){return;}
 | |
| choices.clearInput();});const setNewCategory=(()=>{const new_category=input.value;choices.clearInput();if(!new_category.length){return;}
 | |
| const new_option=new Option(new_category,new_category);select.add(new_option);select.value=new_category;choices._addChoice(new_option);choices._triggerChange(new_category);choices.setChoiceByValue(new_category);choices.clearInput();});});})();
 |