views:

613

answers:

1

I'm trying to create a link from an external site that arrives at a particular, internal panel on a JQTouch site I'm building. However the browser always opens the home panel of the JQT site no matter what anchor tag I use in the link.

e.g. If I try to link to the User Interface panel in the official JQTouch demo I use http://www.jqtouch.com/preview/demos/main/#ui but the home panel shows in the browser and not the sub-panel I requested.

Any suggestions would be very welcome. I have control of the both the linked and linking sites so can tweak code is necessary.

Thanks

+1  A: 

According to the source code (http://code.google.com/p/jqtouch/source/browse/trunk/jqtouch/jqtouch.js) - jqTouch will load whatever portion of your page first has the current class added to it.

Line 179 of jqtouch.js:

// Make sure exactly one child of body has "current" class
if ($('#jqt > .current').length == 0) {
  currentPage = $('#jqt > *:first');
} else {
  currentPage = $('#jqt > .current:first');
  $('#jqt > .current').removeClass('current');
}

// Go to the top of the "current" page
$(currentPage).addClass('current');
location.hash = '#' + $(currentPage).attr('id');
addPageToHistory(currentPage);

So the best thing to do might be to check your window.location.hash variable before you run the jqtouch source, and set which ever hash is there to the current class.

Something along the lines of this heuristic:

<script include jquery>
<script>
var cur = document.location.hash;
if (cur) {
  $('.current').removeClass('current');
  $(cur).addClass('current');
}
</script>
<script include jqtouch>
Alex Sexton