I'm using a Checkbox component, and it is being returned in a dinamically-sized loop (items array is variable in length and content), so that it looks like the following:
Hello.
Yes, thanks.
Doing the bind on the onChange property when the is called, I can pass additional parameters to the callback function, as you suggested.
If I pass the "i" parameter there, I get the proper value on the callback.
Right now, I have the following:
<Checkbox checkboxClass={chkboxclass} increaseArea="20%" label={item.title} defaultChecked onChange={hdlchangefn.bind(this, item, i)}/>
My question now is:
Given the above, how can I get the "checked" value now?
If I declare the callback function as:
handleChange(item, i, checked) { ... }
I get checked as an 'object', not a boolean.
Hello.
I'm using a Checkbox component, and it is being returned in a dinamically-sized loop (items array is variable in length and content), so that it looks like the following:
So, I need the onChange handler "hdlchangefn" to be a unique function, to be used no matter which Checkbox invoked it.
Is there any way in the hdlchangefn handler to access the id "i" of the enclosing
Thanks a lot. -Bob V
Hello. Yes, thanks. Doing the bind on the onChange property when the is called, I can pass additional parameters to the callback function, as you suggested.
If I pass the "i" parameter there, I get the proper value on the callback.
Right now, I have the following:
<Checkbox checkboxClass={chkboxclass} increaseArea="20%" label={item.title} defaultChecked onChange={hdlchangefn.bind(this, item, i)}/>
My question now is: Given the above, how can I get the "checked" value now?If I declare the callback function as:
handleChange(item, i, checked) { ... }
I get checked as an 'object', not a boolean.Thanks a lot. Bob V.
Hello. Forget about my last question.
I've already found a solution, by means of data-mode property.
Thanks.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind