fix active tab selection. "this" changes regarding the context
[plewww.git] / 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);
 
 };