Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in 1 javascript file affecting another?

Status
Not open for further replies.

hitchyali

Technical User
Mar 5, 2009
5
GB
Hey Guys,

Problem in question can be seen on the right side of the pages linked - the right sidebar. Filter Category and Filter Date drop-downs.

I have a hidden container (.show-container) which shows when a user clicks on a link (.toggle-trigger).

On this page ( the toggle works correctly; the hidden container shows/hides itself when .toggle-trigger is clicked.

However, on this page ( we have the exact same code (as it is the exact same element pulled in via PHP) but the hidden container does not show/hide itself when .toggle-trigger is clicked.

I am aware that there is a problem with a different javascript file called aside-scroll.js and firebug shows the error as:

$("#scrollbox").offset() is null
[Break on this error] var top = $('#scrollbox').offset().to...ss('margin-top').replace(/auto/, 0));

Is it possible that the error in this JS file could be affecting the other JS file?

I am so confused at to why the javascript file in question (slide-toggle.js) would work on one page and not another.

Hope somebody have an idea!

Many Thanks,
Ali
 
Of course its affecting it. When the JS encounters an error it stops. It does not keep running the JS after an error, so whatever other JS may be there is not being executed.

Looking at the archives page source code there doesn't appear to be an element with an ID of scrollbox anywhere. Unless is dynamically being added after the page loads, and then it may be trying to use the element before its actually loaded.





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Solved! Many thanks for that information Vacunita.

I did not know that if JS encouters and error in 1 file, it simply stops all together. What I have done now is put the
<script type="text/javascript" src="/wp-content/themes/alihitch/js/aside-scroll.js"></script> on the specific page rather than the header.

Voila! It now works.

Many Thanks Again,
Ali
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top