samsono / Easy-Responsive-Tabs-to-Accordion

Easy responsive tabs - is a lightweight jQuery plugin which optimizes normal horizontal or vertical tabs to accordion on multi devices like: web, tablets, Mobile (IPad & IPhone). This plugin adapts the screen size and changes its action accordingly.
Other
603 stars 260 forks source link

How to Activate tab from an anchor on the same page? #72

Open shofer4eto opened 8 years ago

shofer4eto commented 8 years ago

Hi,

Awesome plugin! How do I activate a tab by clicking on an anchor on the Same page? For example I have some tabs, then at the bottom of the page I have a button that links to "#tab1", I want clicking on it to activate "tab1" from my tabs? Thanks in advance!

tinsterman commented 8 years ago

Quickest way is put the full url including the tab anchor eg http://www.mysite.com/#tab1

shofer4eto commented 8 years ago

Hi,

I don't want the page to reload though...

pyrobob83 commented 8 years ago

Did you ever figure this out shofer4eto? I'd like to do the same thing and even using the full URL doesn't work for me in FF or Chrome.

millermultimedia commented 8 years ago

This worked for me. First add a class to all Anchor tags with the local hashtag. At the bottom of the easyResponsiveTabs.js file, add the following:

jQuery(document).ready(function () { jQuery(".linkClass").click(function () { var hash = jQuery(this).attr('href').replace(/^.*?#/,''); window.location.hash = "#"+hash; location.reload(); }); });

Replace "linkClass" with the class you used on your anchors. This is kind of crude. jQuery will monitor the hash tag links. When they are clicked it will grab the hash, append it to the page URL and reload the page.

p44v9n commented 7 years ago

Surely there must be a less crude way, this^ effectively is the same as linking to the full URL