Sivo Posted February 14, 2014 Share Posted February 14, 2014 (edited) Hello, I am trying to resolve a little problem, since I just want to open a tab with a external link (I mean the link is outside of the tab div) in the same page, but it does not work following the html logic. Main code when selected (this <a> is inside the tab): <a id="more_info_tab_more_info" class="matricula selected" href="#idTab1111111">¡Matriculate ya!</a> Reasonable code (this <a> is outside the tab and should open the one inside the tab): <a href="#idTab1111111" id="more_info_tab_more_info">¡Matriculate ya!</a> But for some reason it does not work. Also I found the .js file wich creates the idTab function, but I am not able to find the clue to make the same function with a external link. Js idTab (function ($) { $.fn.idTabs = function () { var s = { "start": null, "return": false, "click": null }; for (var i = 0; i < arguments.length; ++i) { var n = {}, a = arguments[i]; switch (typeof a) { case "object": $.extend(n, a); break; case "number": case "string": n.start = a; break; case "boolean": n["return"] = a; break; case "function": n.click = a; break; }; $.extend(s, n); } var self = this; var list = $("a[href^='#']", this).click(function () { if ($("a.selected", self)[0] == this) return s["return"]; var id = "#" + this.href.split('#')[1]; var aList = []; var idList = []; $("a", self).each(function () { if (this.href.match(/#/)) { aList[aList.length] = this; idList[idList.length] = "#" + this.href.split('#')[1]; } }); if (s.click && !s.click(id, idList, self)) return s["return"]; for (i in aList) $(aList[i]).removeClass("selected"); for (i in idList) { $(idList[i]).addClass('block_hidden_only_for_screen'); } $(this).addClass("selected"); $(id).removeClass('block_hidden_only_for_screen'); return s["return"]; }); var test; if (typeof s.start == "number" && (test = list.filter(":eq(" + s.start + ")")).length) test.click(); else if (typeof s.start == "string" && (test = list.filter("[href='#" + s.start + "']")).length) test.click(); else if ((test = list.filter(".selected")).length) test.removeClass("selected").click(); else list.filter(":first").click(); return this; }; $(function () { $(".idTabs").each(function () { $(this).idTabs(); }); }); })(jQuery) Any idea? Edited February 14, 2014 by Sivo (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts