fix active tab selection. "this" changes regarding the context
authorBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Mon, 15 Jun 2009 11:43:27 +0000 (11:43 +0000)
committerBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Mon, 15 Jun 2009 11:43:27 +0000 (11:43 +0000)
plekit/linetabs/linetabs.js

index 6430e0f..b0203e7 100644 (file)
@@ -58,11 +58,6 @@ linetabs.prototype.init = function (div) {
       mt.setActive (mt.activeTab,false);
     });
 
-  /* set active and current, default is index 0, set 'active' class otherwise */
-  this.input_s.each ( function (input) {
-      if (input.hasClassName("active")) this.activeTab = this.currentTab = i;
-    });
-
   /* create slice object */
   this.slideObj    = this.ul.parentNode.appendChild(document.createElement("div"));
   this.slideObj.appendChild(document.createTextNode(String.fromCharCode(160)));
@@ -76,6 +71,13 @@ linetabs.prototype.init = function (div) {
   this.aHeight                 = (this.ul.offsetTop + this.li_s[this.activeTab].offsetTop +
                                  this.input_s[this.activeTab].offsetTop);
 
+  my_object = this;
+  /* set active and current, default is index 0, set 'active' class otherwise */
+  this.input_s.each ( function (input, index) {
+      if (input.hasClassName("active")) my_object.activeTab = my_object.currentTab = index;
+  });
+
+
   this.initSlide(this.activeTab, true);
 
 };