Clientcide: TabSwapper

40 views
Skip to first unread message

Philip Thompson

unread,
Nov 11, 2012, 11:37:38 PM11/11/12
to mootool...@googlegroups.com
Hi. I am having some issues with TabSwapper. I can add tabs successfully, but once I remove one, I can no longer add any more tabs. There are some errors that occur - see the console when adding/removing tabs. Any insight as to what's going on?

http://jsfiddle.net/philthathril/ZmY5k/

Also, it appears as though the "show" method doesn't work (when the remove button is clicked).

Thanks in advance,
~Philip

Johnny Fuery

unread,
Nov 11, 2012, 11:48:00 PM11/11/12
to mootool...@googlegroups.com
Your indexes are messed up. A zero-indexed array with length x has an index of zero through (index - 1). You're trying to access the tabs array with an index that is out of bounds.

Every place where you are trying to access array[array.length], use array[array.length - 1] and you should be good to go.

Johnny Fuery
President/Principal Engineer
Fuery Solutions -- makers of MerusCase
1736 Franklin Street, Suite 350
Oakland, CA 94612

Philip Thompson

unread,
Nov 11, 2012, 11:52:28 PM11/11/12
to mootool...@googlegroups.com
Ok, good catch. Silly me. That explains the removing. But what about the error that's thrown when adding a tab after removing one?

"TypeError: element is null"
"var parent = element.parentNode"

Thanks
~Philip

Philip Thompson

unread,
Nov 12, 2012, 12:18:53 AM11/12/12
to mootool...@googlegroups.com
Figured this out. The tabs property on the TabSwapper is not getting updated when a tab is removed. I added this line to get around this...

ts.tabs.erase(ts.tabs[index-1]);


This *seems* like a bug to me, but I'll let Aaron determine that.

Thanks,
~Philip

Aaron Newton

unread,
Nov 12, 2012, 12:33:02 AM11/12/12
to mootool...@googlegroups.com
I ♥ pull requests.
Reply all
Reply to author
Forward
0 new messages