i wrote a function that help me to bind view and model. the function is this
const[data, setData] = useState({});
const bind = (e) => {
if(e.target.value !== undefined) {
let value = e.target.value;
setData({...data, [e.target.id]: value});
}
else if(e.checked !== undefined) {
setData({...data, [e.target.id]: e.target.checked});
}else{
alert("Binding fails.")
}
console.log(e)
}
And to used it. i can dot something like that.
In case of inputText :
<div className="field">
<InputText id="id" value={data.id} onChange={bind} />
</div>
In case of Password
<div className='field'>
<Password inputId="password" value={data.password} onChange={bind} />
</div>
The challeng for me is to member that depending to the view, the propertie to used.
for instance in case of Password, Calendar, Chips, i do have to use InputId but in case on InputText, InputMask, i do have to use id, otherwise it will not work.
so i is very difficult to work like that. i want to know if there is a consistent property that can be used for all views.
thanks
When use <<inputId>> instead of <<id>>
It all depends on whether its a wrapped component. The `id` will go on the wrapper so like in Password its wrapped in a "DIV" so the Input is inside the div. So basically consulting the documentation of each component is how you know.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
-
- Information
-
Who is online
Users browsing this forum: No registered users and 26 guests