mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
Fixed TabController infinite Loop
This commit is contained in:
@ -11,6 +11,7 @@ TabBarItem.prototype = {
|
||||
var item = document.createElement('a');
|
||||
item.className = 'tab-item';
|
||||
|
||||
// If there is an icon, add the icon element
|
||||
if(itemData.icon) {
|
||||
var icon = document.createElement('i');
|
||||
icon.className = itemData.icon;
|
||||
@ -108,7 +109,8 @@ TabBar.prototype = {
|
||||
|
||||
if(!this._itemTapHandler) {
|
||||
this._itemTapHandler = function(e) {
|
||||
_this.selectItem(this);
|
||||
//_this.selectItem(this);
|
||||
_this.trySelectItem(this);
|
||||
};
|
||||
}
|
||||
item.onTap = this._itemTapHandler;
|
||||
@ -131,7 +133,7 @@ TabBar.prototype = {
|
||||
// Select the new item
|
||||
if(this.selectedItem) {
|
||||
this.selectedItem.setSelected(true);
|
||||
this.onTabSelected && this.onTabSelected(this.selectedItem, index);
|
||||
//this.onTabSelected && this.onTabSelected(this.selectedItem, index);
|
||||
}
|
||||
},
|
||||
|
||||
@ -146,6 +148,15 @@ TabBar.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
trySelectItem: function(item) {
|
||||
for(var i = 0, j = this.items.length; i < j; i += 1) {
|
||||
if(this.items[i] == item) {
|
||||
this.tryTabSelect && this.tryTabSelect(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Build the initial items list from the given DOM node.
|
||||
_buildItems: function() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user