mercredi 19 août 2015

Mimicking checkbox changes with Jquery and React.js

I have a react component rendering a checkbox with an attached onChange event:

<input type='checkbox' onChange={this.handleChange} />

Outside of the react stuff I also have some JQuery. We (for reasons beyond the scope of this) people want to be able to select a checkbox via some Js in the JQuery code. Whilst we can easily select the checkbox using:

item.prop('checked', true);

I am unable to get the onChange event within the React component to trigger.

Is there something I can do (maybe dispatch some sort of event or something) that will make React, well, react and do whatever the onChange handler would do if I had clicked the checkbox manually?




Aucun commentaire:

Enregistrer un commentaire