Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass selected tab to onChange event #384

Merged
merged 3 commits into from
Mar 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/src/app/components/pages/components/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var Tabs = mui.Tabs;
var Tab= mui.Tab;

var TabsPage = React.createClass({

mixins: [Router.Navigation, Router.State],

render: function(){
Expand Down Expand Up @@ -51,7 +51,7 @@ var TabsPage = React.createClass({
'If you need to access a tab directly - you can do so with the first argument of onActive or ' +
'by accessing the props.children array by passing refs to the Tabs container.';



var componentInfo = [
{
Expand All @@ -70,7 +70,7 @@ var TabsPage = React.createClass({
infoArray: [
{
name: 'onChange',
type: 'function',
type: 'function(tabIndex, tab)',
header: 'optional',
desc: 'Fired on touch or tap of a tab.'
}
Expand Down
9 changes: 6 additions & 3 deletions src/js/tabs/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ var Tabs = React.createClass({
},

handleTouchTap: function(tabIndex, tab){
if (this.props.onChange && this.state.selectedIndex !== tabIndex) this.props.onChange();
if (this.props.onChange && this.state.selectedIndex !== tabIndex) {
this.props.onChange(tabIndex, tab);
}

this.setState({selectedIndex: tabIndex});
//default CB is _onActive. Can be updated in tab.jsx
if(tab.props.onActive) tab.props.onActive(tab);
},

render: function(){
var _this = this;
var _this = this;
var width = this.state.fixed ?
this.state.width/this.props.children.length :
this.props.tabWidth;
Expand Down Expand Up @@ -84,4 +87,4 @@ var Tabs = React.createClass({

});

module.exports = Tabs;
module.exports = Tabs;