Sunday, 15 August 2010

reactjs - onClick event isn't firing on React Component -



reactjs - onClick event isn't firing on React Component -

i'm working on component stub have grid of tiles, each require click handler, , specific "new" tile has different click handler. i'm trying click handlers working correctly, event never seems fire.

any ideas?

var grid = react.createclass({ oncreatenew: function () { console.log("oncreatenew"); }, render: function () { var tiles = []; if (this.props.items) { tiles = this.props.items.map(function (item, index) { //create tile each item }); } //always append "new" tile lastly 1 tiles.push(react.dom.div({ onclick: this.oncreatenew, classname: "tile new_tile" }, react.dom.div({ classname: "plus", onclick: this.oncreatenew }, "+") )); homecoming react.dom.div({ id: "flowsheetpane" }, tiles); } });

as commenters have mentioned, code appears work expected in isolation.

react delegates event handlers single event listener @ root of dom, events need propagate way top in order react phone call function.

could have added event listeners somewhere in component hierarchy calling event.stoppropagation()? if did outside of react (e.g. natively or jquery), cause events never reach top of dom, , react never have chance delegate out methods.

reactjs

No comments:

Post a Comment