CSLTech / budibase-autocomplete

Budibase Autocomplete Plugin
1 stars 3 forks source link

On Change Event FIX #4

Open Branteagle opened 3 months ago

Branteagle commented 3 months ago

Sorry about bugging about this, however, I did figure out how to and the onChange event to the selection made.

Add this to the schema.json file

{ "type": "event", "label": "On Change", "key": "onChange", "context": [ { "label": "Field Value", "key": "value" } ] }

Add this to Component.svelte

export let onChange;

Add this to Component.svelte

const handleChange = e => { if (onChange) { onChange({ value: e.detail }); } };

Change this in Component.svelte

function changeHandler(e) { console.log('selectedItem', selectedItem) console.log('changeHandler', e); console.log('searcheventhandler', searchEvent); if (selectedItem) { fieldApi?.setValue(selectedItem[valueFieldName]); handleChange({ detail: selectedItem[valueFieldName] }); } }