Bug Tracker

Opened 12 years ago

Closed 12 years ago

#9559 closed bug (worksforme)

Buggy globalEval

Reported by: Denis G. Owned by:
Priority: low Milestone: 1.next
Component: misc Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:


Hello. In my page include two scripts: Prototype.js and jQuery. And jScrollPane script - include content in new div. If content meets Prototype call function, you get error. In jQuery 1.4.4 - work. Also in my livepage have specifical error (not in example):

$("region_id") is null
<html lang="en"> 

Please, see example page:

http://belvg.info/+bug_reports/prototype_jquery_jscrollpane/demo.html - 1.6.1

http://belvg.info/+bug_reports/prototype_jquery_jscrollpane/demo2.html - 1.4.4

Change History (1)

comment:1 Changed 12 years ago by addyosmani

Component: unfiledmisc
Priority: undecidedlow
Resolution: worksforme
Status: newclosed

Thanks for submitting a ticket to the jQuery Project!

Please note that in your 1.4.4 example, you aren't actually including Prototype in your page. You're simply using similar scrollbar logic coupled with a jQuery(elem).css() call.

Solution 1: ===============

I've gone through your code and the issue with it may be that you're attempting to use Prototype's .setStyle() without checking to see if the DOM, window or any of your scripts have finished loading. Effectively this may be causing an exception (' Cannot call method 'setStyle' of null') which is breaking things because Prototype likely hasn't completed loading at that point. By simply moving your setStyle call after the jsScrollPane line (inside your $(document).ready()), I'm able to get the Prototype + jQuery version of your page working fine.

Alternatively you can use a Prototype or JS-specific load event to achieve the same.

Solution 2: ================

This is significantly more straight-forward, but by moving your Prototype call to after your jQuery(document).ready() (ie, after '});', you can also get it working fine. This may have something to do with time-related behaviour the jScrollPane plugin may be applying, however both of the proposed solutions should solve your problem. Neither of them indicate the issue to be with jQuery core.

Note: See TracTickets for help on using tickets.