typedInput API type/types query

https://nodered.org/docs/api/ui/typedInput/

In the docs it lists 3 Options;
image

But in the examples is has type which is not listed as an option.

image

Is type the default for this input? Could I replace type:'str' with type:'num' such that the default selection is num?

Does type and default mean the same thing?

I think so yes.

1 Like

That is a mistake in the docs. You should use default not type to set the initial type of the input.

1 Like

@knolleary I saw in another thread you said you'd updated the docs and wanted some feedback.

I note the use of single and double quotes appears to not be consistent. If some instances need to be single /double, it would be useful to state that (or it might be a standard Javascript thing).

e.g.
image

image

I'm also not clear in the first clip above if $(.input). would ever be used as I understood it would always be of the form #node-input-.

If there is to be only one type, does the types array need to be defined (Clip 2 above).

My other thought is that I still do not understand why I would use the typeField. I have experimented but cannot see what impact it has. Some additional explanation and perhaps an example would be useful.

Just the view from coming to this for the first time - I understand how hard documentation is :).

Single and double-quotes are equal in JavaScript.

1 Like

Hi @borpin

Im sure you read the explanation in the docs but just in case...

In some circumstances it is desirable to already have an <input> element to store the type value of the typedInput. This option allows such an existing element to be provided. As the type of the typedInput is changed, the value of the provided input will also change.

To paraphrase - if you add a hidden input element & provide it's selector to the typeField property, the typedInput will store your selection for you, meaning (for example) you don't need to save it's value manually in oneditsave

2 Likes

Ah, yes, that makes sense - or rather it explains it in a way I understand (always the problem with documentation), thanks :grinning:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.