node-red / node-red/node-red.github.io
Creating your own Node - where to add TypedInput on('change') event handlers
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 118
- Fork
- 161
- Merge medio
- 8h 18m
- PR unite (30g)
- 4
Descrizione
This issue is to suggest a couple of areas where documentation could be improved. Documentation is otherwise very good.
I haven't been able to find documentation for when in time to add a function to watch for change events as documented here. For example, to show/hide or enable/disable an HTML element based on a value of one of the Node properties.
Adding this within oneditprepare does not work ...
$('#node-input-instruction').on('change', (event, type, value) => {
if (value === 'turn_on') {
$('#node-wrapper-speed').typedInput('enable');
$('#node-wrapper-timeout').typedInput('enable');
} else if (value === 'turn_off') {
$('#node-wrapper-speed').typedInput('disable');
$('#node-wrapper-timeout').typedInput('disable');
}
});
... because you get an error since you can't call the typedInput function this early. Is there an official/recommended callback we should be using for once the UI has been setup (added to the DOM, or whaterver work you do)? In the meantime, I am setting hide/show directly on various elements, rather than using typedInput().
Can the documentation in Node Properties and/or TypedInput Widget be updated to make this easier to understand, to provide examples of method calls? Or maybe I've just missed something in the documentation.
If I am confused, maybe others are as well (or maybe they are better at reading documentation).
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Rivedi docs/creating-nodes/properties.md alla sezione “Custom edit behavior” e docs/api/ui/typedInput/index.md nelle sezioni “Methods” e “Disable state”. Confronta la tempistica del change-event di TypedInput documentata con l’esempio di oneditprepare nell’issue. Il lavoro è completato quando la documentazione spiega quando gli handler possono chiamare i metodi di TypedInput e include un esempio funzionante.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100