Trait BindAttribute
pub trait BindAttribute<Key, Sig, T>where
Key: AttributeKey,
Sig: IntoSplitSignal<Value = T>,
T: FromEventTarget + AttributeValue + 'static,{
type Output;
// Required method
fn bind(self, key: Key, signal: Sig) -> Self::Output;
}
Expand description
Adds a two-way binding to the element, which adds an attribute and an event listener to the element when the element is created or hydrated.
Required Associated Types§
type Output
type Output
The type of the element with the two-way binding added.
Required Methods§
fn bind(self, key: Key, signal: Sig) -> Self::Output
fn bind(self, key: Key, signal: Sig) -> Self::Output
Adds a two-way binding to the element, which adds an attribute and an event listener to the element when the element is created or hydrated.
Example:
ⓘ
// You can use `RwSignal`s
let is_awesome = RwSignal::new(true);
// And you can use split signals
let (text, set_text) = signal("Hello world".to_string());
// Use `Checked` and a `bool` signal for a checkbox
checkbox_element.bind(Checked, is_awesome);
// Use `Group` and `String` for radio inputs
radio_element.bind(Group, (text, set_text));
// Use `Value` and `String` for everything else
input_element.bind(Value, (text, set_text));
Depending on the input different events are listened to.
<input type="checkbox">
,<input type="radio">
and<select>
use thechange
event;<input>
with the rest of the types and<textarea>
elements use theinput
event;