Permalink
Browse files

feat: tabs组件增加切换页签时的监听

  • Loading branch information...
LiuYueKai committed Apr 12, 2017
1 parent 038d3ad commit 10ee208b916609a4d1fc39faab5977e41bc705d2
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/neoui-tabs.js
@@ -81,6 +81,14 @@ var Tabs = u.BaseComponent.extend({
addClass(panel, this._CssClasses.ACTIVE_CLASS);
},
getIndex: function(tab) {
var tabs = this.tabs_;
for (var i = 0; i < tabs.length; i++) {
if (tabs[i] == tab)
return i;
}
return -1;
},
/**
* Initialize element.
@@ -120,8 +128,15 @@ function Tab(tab, ctx) {
ctx.resetPanelState_();
addClass(tab, ctx._CssClasses.ACTIVE_CLASS);
addClass(panel, ctx._CssClasses.ACTIVE_CLASS);
var index = ctx.getIndex(tab);
ctx.trigger('tabchange', {
tabDom: tab,
index:index
})
});
}
}

0 comments on commit 10ee208

Please sign in to comment.