Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update typedInput to include an example with change event #379

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 58 additions & 4 deletions docs/api/ui/typedInput/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,12 @@ RED.nodes.registerType('example', {
```



### Methods

<a name="methods-type"></a>

Note that methods can only be called after setting the typedInput options.

#### <a href="#methods-disable" name="methods-disable">disable( state )</a>

*Since Node-RED 1.2.7*
Expand Down Expand Up @@ -191,8 +192,6 @@ Enable the typedInput when it is currently disabled.
$(".input").typedInput('enable');
```



#### <a href="#methods-hide" name="methods-hide">hide()</a>

Hide the typedInput when it is currently visible.
Expand Down Expand Up @@ -274,6 +273,7 @@ Sets the width of the typedInput.
$(".input").typedInput('width', '200px');
```


### Events

#### <a href="#events-change" name="events-change">change( event, type, value )</a>
Expand All @@ -286,6 +286,7 @@ $(".input").on('change', function(event, type, value) {} );

*Note:* The `value` property was added in Node-RED 1.3


### Types

#### <a href="#types-typedefinition" name="types-typedefinition">TypeDefinition</a>
Expand Down Expand Up @@ -396,6 +397,41 @@ $("#node-input-example5").typedInput({type:"fruit", types:[{

<div class="red-ui-editor"><input type="text" id="node-input-example5"></div>

#### Update types from change event

```html
<input type="text" id="node-input-example6-1">
<input type="text" id="node-input-example6-2">
```

```javascript
$("#node-input-example6-1").typedInput({type:"mode", types:[{
value: "mode",
options: [
{ value: "static", label: "Static"},
{ value: "dynamic", label: "Dynamic"},
]
}]})

$("#node-input-example6-2").typedInput({
type:'str',
types:['str','env']
})

$("#node-input-example6-1").on("change", function(event, type, value) {
if (value == "static") {
$("#node-input-example6-2").typedInput("types", ['str','env'])
} else {
$("#node-input-example6-2").typedInput("types", ['flow','global','msg'])
}
})
```

<div class="red-ui-editor">
<input type="text" id="node-input-example6-1">
<input type="text" id="node-input-example6-2">
</div>


### Runtime handling of typed values

Expand Down Expand Up @@ -502,6 +538,24 @@ $(function() {
{ value: "banana", label: "Banana"},
{ value: "cherry", label: "Cherry"},
]
}]})
}]})
$("#node-input-example6-1").typedInput({type:"mode", types:[{
value: "mode",
options: [
{ value: "static", label: "Static"},
{ value: "dynamic", label: "Dynamic"},
]
}]})
$("#node-input-example6-2").typedInput({
type:'str',
types:['str','env']
})
$("#node-input-example6-1").on("change", function(event, type, value) {
if (value == "static") {
$("#node-input-example6-2").typedInput("types", ['str','env'])
} else {
$("#node-input-example6-2").typedInput("types", ['flow','global','msg'])
}
})
});
</script>