Issue with javascript in the tableheader.js function. The dimensions plugin using 1.2 no longer has offset which was moved to the core. So when using offset on line 73

var scrollLocation = $('td'+ location.hash).offset().top - $(e).height();

It gives an error if the table is not currently pre-populated and the # is utilized in the query string when looking at comments for a node for instance.

The below code should resolve this issue.

       var offset = $('td' + location.hash).offset();
        if (offset) {
          var top = offset.top;
          var scrollLocation = top - $(e).height();
          $('body, html').scrollTop(scrollLocation);
        }
CommentFileSizeAuthor
#46 tableheader_jquery1.7_capability-325810-46.patch552 bytesacbramley
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es). View
#44 tableheader_jquery1.7_capability-325810-44.patch617 bytesLeksat
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es). View
#43 tableheader-1239653-42.patch658 bytesLeksat
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es). View
#42 tableheader-1239653-42.patch622 bytesLeksat
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es). View
#36 tableheader.patch543 bytesrgarand
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in tableheader_8.patch. View
#15 tableheader.patch701 bytesmiglius
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch tableheader_1.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots. View
Tag1 supports Drupal development!Tag1 logo

Comments

Dave Reid’s picture

Marked #327292: Link to comment Disables Javascript as a duplicate of this issue. I can duplicate this issue on my own site. Just core Drupal, loading a page like http://mysite/node/1#comment-1 causes the error. I'll look into this more to see if this fixes the issue.

Flying Drupalist’s picture

Priority: Normal » Critical

I'll subscribe. Where does the code above go?

xmacinfo’s picture

Title: Issue when using dimensions jquery plugin in tableheader.js » Issue when using dimensions jquery plugin

Dave marked #302488: Fieldsets not expandable in Drupal 6.4 and up with a # in the URL Fieldsets not expandable in Drupal 6.4 and up with a # in the URL as a duplicate of this issue.

Dave Reid’s picture

Title: Issue when using dimensions jquery plugin » Issue when using dimensions jquery plugin in tableheader.js

You beat me to it! I also marked #328538: Broken code in tableheader.js as a duplicate of this issue.

xmacinfo’s picture

Which markup are you using to make the dup bug strikethrough? :-)

Dave Reid’s picture

From the Input format help below..."Project issue numbers (ex. [#12345]) turn into links automatically." :)

darren.ferguson’s picture

Title: Issue when using dimensions jquery plugin » Issue when using dimensions jquery plugin in tableheader.js

File is tableheader.js on Line #73

Flying Drupalist’s picture

Thank you so much darren.ferguson, works for me.

Flying Drupalist’s picture

I just want to report that Safari and Chrome are still broken.

whyameye’s picture

Version: 6.6 » 6.8

this bug still exists in D6.8 and the code to fix still works (at least for FF3). Will this patch be incorporated in 6.9?

Manuel Garcia’s picture

Just wanted to confirm this is still an issue in 6.8

Gurpartap Singh’s picture

Version: 6.8 » 6.9

Still applies in 6.9. This completely disables all the JavaScript when you visit a page with a fragment.

See http://myzonelabs.com/node/14#comment-138.

Can we get this fixed please?

Dave Reid’s picture

Version: 6.9 » 6.x-dev
Issue tags: +JavaScript, +Quick fix

Let's get a patch made so it can be properly reviewed.

Dave Reid’s picture

Priority: Critical » Normal
Status: Needs review » Active
miglius’s picture

FileSize
701 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch tableheader_1.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots. View

I have attached the patch in the proper format.

Dave Reid’s picture

Status: Active » Needs review
Dave Reid’s picture

Marked #367088: tableheader.js error with anchors as a duplicate of this issue.

egfrith’s picture

The patch at #325810-15: Issue when using dimensions jquery plugin in tableheader.js applies and works for me under FF 2.0.0.12. As far as I can see, the logic of it appears to be correct, and the coding style appears to be correct too.

hgmichna’s picture

This is probably no longer needed, but I'm posting it just in case as a reinforcement. The following happens in Internet Explorer 7 and Drupal 6.9.

Even if it can be avoided by improving Drupal, it does look superficially like a jQuery bug to me, and I've pondered the thought of reporting it as such. I think, no matter how the web pages are designed, jQuery should not crash like that.

http://winhlp.com/node/10#comment-869

Error in line 753: offset().top is null or not an object.

001:// $Id: jquery.js,v 1.12.2.3 2008/06/25 09:38:39 goba Exp $
002:
003:/*
004: * jQuery 1.2.6 - New Wave Javascript
...
749: // Check the previous anchor to see if we need to scroll to make room for the header.
750: // Get the height of the header table and scroll up that amount.
751: if (prevAnchor != location.hash) {
752: if (location.hash != '') {
753: var scrollLocation = $('td'+ location.hash).offset().top - $(e).height();
754; $('body, html').scrollTop(scrollLocation);
755: }
756: prevAnchor = location.hash;
757: }

radj’s picture

Additional info:
It isn't just about comments. I think it's about the URL having an anchor in it. Javascript seems to go Off when in the following places:
www.site.com/node/32#test
www.site.com#any

But it doesn't occur if only the pound sign is there. ex:
1 - go to another site (ex: http://www.google.com)
2 - go to http://www.site.com# (note the extra #)
I intentionally did 1 to make sure that I visited the page, not just making the browser try to point to the anchor in the page.
Anyway, the result is, the site goes to "http://www.site.com/" -- the pound sign disappears and all JS is good.

Also, accessing http://www.site.com/# (slash then #) doesn't affect the JS, everything works fine.

Hope this info helps.

Using D6.9

EDIT -- and the patch in #15 fixes it.

xmacinfo’s picture

Damien Tournoud’s picture

Issue tags: +drupal.org upgrade

This affects d.o badly too.

Gurpartap Singh’s picture

Priority: Normal » Critical
webchick’s picture

Damien checked and this does not appear to affect 7.x since we now use jQuery 1.3 and presumably it became smarter some time. Or else we accidentally fixed this as part of the changes necessary to get Drupal 7 to work with jQuery 1.3.

In any case, this only needs fixing in 6.x. :) But fixing it on d.o ASAP would be a good and wonderful thing.

cwgordon7’s picture

Status: Needs review » Reviewed & tested by the community

I tested this bug at admin/build/modules#system-modules on a fresh drupal 6-dev installation, javascript was broken on the entire page with the anchor, but worked fine without it. After the patch was applied, it worked smoothly both ways. I tested on the browsers currently available to me, which happened to be firefox 3 and konqueror, and the patch worked for both of them. Along with the comments in #18, I think this is rtbc.

richguynextdoor’s picture

This same issue existed for me in drupal 6.10. When a file was attached to a node it would break the javascript when trying to add a comment. The FCKeditor would not overlap the current text box, and the input option menu would no longer be expandable.

I applied the patch referenced in comment #15 and it fixed the issue for both Firefox 3.0.7 and internet explorer 8.

bob.hinrichs’s picture

Version: 6.x-dev » 6.10

subscribe. getting same error using Drupal 6.10

cwgordon7’s picture

Version: 6.10 » 6.x-dev

Since this issue still exists in the development version, it is listed under the development version and not any specific release.

webchick’s picture

Issue tags: -drupal.org upgrade

w00t!! David Strauss applied this to d.o and it works great. :) (your squid timeout may vary)

Removing drupal.org upgrade tag, still needs committing to 6.x proper.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Committed to Drupal 6. Thanks!

markus_petrux’s picture

Version: 6.x-dev » 7.x-dev
Status: Fixed » Needs work

Fix not committed too HEAD.

Dave Reid’s picture

Version: 7.x-dev » 6.x-dev
Status: Needs work » Fixed

See #24: "Damien checked and this does not appear to affect 7.x since we now use jQuery 1.3 and presumably it became smarter some time. Or else we accidentally fixed this as part of the changes necessary to get Drupal 7 to work with jQuery 1.3."

If you can confirm this is still a problem on HEAD, go ahead and re-open this.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rgarand’s picture

Version: 6.x-dev » 6.19
Priority: Critical » Normal

Unfortunately there is still a related error. I recently found that sharing links on Facebook adds a hash to them like #.TlfKSwI4roo.facebook which causes a jQuery error, so anyone who clicked on the link would get a page with no Javascript. Further testing has shown that the first . is the cause of the error. This might be a fairly simple case to detect and correct in the tablesort file.

rgarand’s picture

Status: Closed (fixed) » Active
rgarand’s picture

FileSize
543 bytes
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in tableheader_8.patch. View

After external fixes in the theme proved to be unreliable, I changed line 72 of tableheader.js to the following which corrected the error:

if (location.hash != '' && location.hash.indexOf('.') != 1) {

xmacinfo’s picture

Status: Active » Needs review

For your patch.

Status: Needs review » Needs work

The last submitted patch, tableheader.patch, failed testing.

xmacinfo’s picture

Version: 6.19 » 6.x-dev
Status: Needs work » Needs review

We probably need to tell the bot to test against 6.x-dev.

Did you roll your patch against 6.x-dev?

rgarand’s picture

It's from 6.19 but it was generated by Windiff so it may be the patch format...

xmacinfo’s picture

You need to roll against the 6.x-dev or the bot will fail.

Leksat’s picture

FileSize
622 bytes
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es). View

The main problem is sitting here:

if (location.hash != '') {
  var offset = $('td' + location.hash).offset();
    if (offset) {
      ...

Variable "offset" always equals to "true" because it is an object. If $('td' + location.hash) doesn't exist, "offset" is "{top=0, left=0}". So, first we should do is check whether $('td' + location.hash) exists on the page:

if (location.hash != '' && $('td' + location.hash).size()) {
  var offset = $('td' + location.hash).offset();
    if (offset) {
      ...
Leksat’s picture

FileSize
658 bytes
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es). View

I think I found more beauty way.

Leksat’s picture

FileSize
617 bytes
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es). View

Patch from #43 updated to work with Jquery 1.7 (#1067290: Fix jQuery 1.7 for Drupal 6).

kentr’s picture

#44 fixed the issue for me, on D6 with jQuery 1.3

Patch didn't apply, though. I seem to recall that Drupal specs for patches are that they should be rolled from with the directory of the file being patched (or, relative to that directory). Looks like perhaps this one wasn't.

acbramley’s picture

Issue summary: View changes
FileSize
552 bytes
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es). View

This issue is still present in 6.34, my issue is it completely stops anchor links working on first click, and stops anchors from other pages working at all. I get no JS console errors though

The patch in #44 no longer applies, here's a slightly more simple, rerolled version against the latest 6.x HEAD, it seems to fix my issues and follows what the patch in #44 was achieving.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.