Hi all,
I have some question regarding the autoComplete with a typedInput:
I wonder what is the correct way to attach autoComplete to a typedInput? Currently I have only found that $(this).parent().find('.red-ui-typedInput-input')
might be the way to go.
When I want to disable autoComplete for a particular type of the typedInput I don't know how to do it. Can someone give a hint?
Hi @ptweety
You can set an autoComplete
option on individual types.
For example, here you can see how we add autocomplete for the built in msg
type:
{ value: "status.source.id", source: ["status"] },
{ value: "status.source.name", source: ["status"] },
{ value: "target", source: ["link call"] },
{ value: "template", source: ["template"] },
{ value: "toFront", source: ["delay"] },
{ value: "url", source: ["http request"] },
{ value: "userProperties", source: ["mqtt"] },
{ value: "_session", source: ["websocket out","tcp out"] },
]
var allOptions = {
msg: {value:"msg",label:"msg.",validate:RED.utils.validatePropertyExpression, autoComplete: autoComplete(msgCompletions)},
flow: {value:"flow",label:"flow.",hasValue:true,
options:[],
validate:RED.utils.validatePropertyExpression,
parse: contextParse,
export: contextExport,
valueLabel: contextLabel
},
global: {value:"global",label:"global.",hasValue:true,
options:[],
validate:RED.utils.validatePropertyExpression,
1 Like
Thank you, @knolleary
So I wrote something like this, which seems to work:
$(this).typedInput({
types: [
{
value: 'str',
label: 'string',
icon: 'red/images/typedInput/az.svg',
autoComplete: function () {
return [
{ value: 'aa', label: 'AA' },
{ value: 'bb', label: 'BB' },
];
},
},
{ value: 're', label: 'regular expression', icon: 'red/images/typedInput/re.svg' },
],
});
Is there a better approach where I do not need to repeat value
, label
, icon
of the default types?
No - we hadn't considered providing a more convenient way to add custom autoCompletes to the existing 'str' option, rather than for an entirely custom type.
What you have is the right way to do it.
system
Closed
19 December 2022 13:02
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.