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

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

未关闭
#332 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
JavaScript
星标
118
派生
161
平均合并
8 小时 18 分钟
30 天内合并 PR
4

描述

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

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

检查 docs/creating-nodes/properties.md 中“Custom edit behavior”部分,以及 docs/api/ui/typedInput/index.md 中“Methods”和“Disable state”附近的内容。将文档所述的 TypedInput change-event 时机与 issue 中的 oneditprepare 示例进行比较。当文档说明 handler 何时可以调用 TypedInput 方法,并包含一个可正常工作的示例时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
documentation
Issue 类型
文档
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。