node-red / node-red/node-red.github.io

Creating your own Node - where to add TypedInput on('change') event handlers

Offen
#332 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
JavaScript
Sterne
118
Forks
161
Ø Merge
8 Std. 18 Min.
Gemergte PRs (30 T.)
4

Beschreibung

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).

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Überprüfe docs/creating-nodes/properties.md unter „Custom edit behavior“ sowie docs/api/ui/typedInput/index.md im Bereich „Methods“ und „Disable state“. Vergleiche den in der Dokumentation beschriebenen Zeitpunkt des TypedInput change-event mit dem oneditprepare-Beispiel im Issue. Die Aufgabe ist erfüllt, wenn die Dokumentation erklärt, wann Handler TypedInput-Methoden aufrufen dürfen, und ein funktionierendes Beispiel enthält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.