Skip to content

Instantly share code, notes, and snippets.

@TechnotronicOz
Created January 7, 2014 19:43
Show Gist options
  • Select an option

  • Save TechnotronicOz/8305529 to your computer and use it in GitHub Desktop.

Select an option

Save TechnotronicOz/8305529 to your computer and use it in GitHub Desktop.
/** @jsx React.DOM */
'use strict';
define(['react'], function(React) {
var NavItem = React.createClass({
render: function() {
return (
<li onClick={this.handleClick} data-page={this.props.page}>{this.props.itemName}</li>
);
},
handleClick: function(e) {
console.log('NavItem.handleClick', e);
this.props.handleIt(e);
}
})
return React.createClass({
render: function() {
var _this = this, i = 0;
try {
var nodes = this.props.navItems.map(function(item) {
++i;
return <NavItem handleIt={_this.dinger} page={i} itemName={item} />;
});
} catch(e) {
console.log('error', e);
}
return (
<nav className="primary">
<ul>
{nodes}
</ul>
</nav>
);
},
dinger: function(e) {
console.log('dinger', e.target.getAttribute('data-page'));
this.props.onClickNext(e.target.getAttribute('data-page'));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment