We're using the older jQuery 1.2.1, and I've tried several methods,  
including your suggestions below. None work in that blasted browser.  
This is the declaration code I'm trying to use in our portal, adapted  
from the basic "how to" page for the datepicker plugin:

        <style type="text/css">@import url(/css/jquery/ui.datepicker.css);</ 
style>
        <script type="text/javascript" src="/js/jquery/ui.datepicker.js"></ 
script>
This is the code that init's the date picker:

        <input type="text" id="dateTest">

        <script>
             $.datepicker.setDefaults({showOn: 'both', buttonImageOnly: true,  
buttonImage: '/images/icons/cal.png', buttonText: 'Calendar'});
             $('#dateTest').datepicker();
             $('#dateTest').datepicker({defaultDate: +7});
        </script>
Tried the following approaches:

1) wrap declaration block in document.ready, as described here:

        http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml

    IE aborts even without code to initialize the date picker

2) declaration block in HEAD. IE aborts
3) declaration right after <BODY> tag, not enclosed by DIV or table  
tags. IE aborts
3) declaration right before </BODY> tag. IE loads it fine
Okay, so we go with #4, and now we try adding the init code somewhere.  
Unfortunately, our pages are user-customizable (think yahoo or google  
portal), so we don't have 100% control over where the init code will  
occur--only that with Approach #4, it will be written to the page  
before the actual declaration.

So I tried wrapping the init code in a document.ready() call as well.  
Works in Firefox, IE barfs (of course), saying the datepicker object  
doesn't exist. I'm trying to force it to load after the declaration  
has in fact occurred, but IE is executing the code as it appears on a  
page.

I could force all components using the date picker to use the same  
variable name, but this is a kludge requiring a try/catch block, since  
there might be no datepicker field. And fun ensues if a user puts two  
picker-equipped portlets a page... This approach also prevents me from  
customizing the datepicker on a case-by-case basis.

Any further suggestions? Has anyone gotten it to work in IE where the  
init code is written to the browser before the declaration?

Thanks for any help.


KidsKilla .grin! wuz here wrote on Dec 12, 2007; 09:56am:
This problem caused in IE not because of jQuery bug, but because of IE  
bug.
IE doesn't allow to work with DOM untill it's fully downloaded and be  
ready.
This is why everything works fine inside $(document).ready()
there is 2 ways to fix it:
1. initialize everything in $(document).ready()
2. paste your script tags in head or directly in body tag. (i mean  
there have to be no parent tags)

search for "Operation aborted"
http://channel9.msdn.com/wiki/default.aspx/Channel9.InternetExplorerProgrammingBugs



Reply via email to