> Just tossing in: Alternately, the <script> block that has the "active" > part can be placed at the end of the document, so the DOM elements are > loaded by the time the browser reaches that <script> tag.
I've never been comfortable relying on that. I've heard people say it, some of them even people who seem like they know what they're doing, but I've never been comfortable *relying* on it. I really should find (or do) some really robust tests, probably a point of ignorance for me. Good catch that his script block *is* at the end. If you can count on elements being in place at that point, any idea why it's failing? -- T.J. On Dec 12, 2:00 am, "joe t." <thooke...@gmail.com> wrote: > > Always makes me eager to jump in and spend my time helping. ;-) > > Nice. > > Just tossing in: Alternately, the <script> block that has the "active" > part can be placed at the end of the document, so the DOM elements are > loaded by the time the browser reaches that <script> tag. You knew > that, but OP maybe didn't. > -joe t. > > On Dec 11, 11:02 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote: > > > > > Hi, > > > > I have not really tried to debug this. > > > Always makes me eager to jump in and spend my time helping. ;-) > > > But the error is obvious enough in this case: You're trying to access > > the DOM from inline script, which won't work; the DOM doesn't exist > > when that script is executed. You need to use the window.load or > > dom:loaded event. > > > document.observe('dom:loaded', function() { > > // Create the autocompleter > > > }); > > > HTH, > > -- > > T.J. Crowder > > Independent Software Consultant > > tj / crowder software / comwww.crowdersoftware.com > > > On Dec 11, 3:10 pm, mjk <mj.kelle...@gmail.com> wrote: > > > > The error must be coming from another method that retrieves > > > 'element'. I have not really tried to debug this. Wondering if > > > anyone else has had this problem, and how they remedied it. > > > > The HTML > > > > <html> > > > <head> > > > <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> > > > <script type="text/javascript" src="http://localhost:4402/author/js/ > > > prototype.js"></script> > > > <script type="text/javascript" src="http://localhost:4402/author/js/ > > > effects.js"></script> > > > <script type="text/javascript" src="http://localhost:4402/author/js/ > > > controls.js"></script> > > > <style type="text/css"> > > > div.autocomplete { > > > position:absolute; > > > width:250px; > > > background-color:white; > > > border:1px solid #888; > > > margin:0; > > > padding:0;} > > > > div.autocomplete ul { > > > list-style-type:none; > > > margin:0; > > > padding:0;} > > > > div.autocomplete ul li.selected { background-color: #ffb;} > > > div.autocomplete ul li { > > > list-style-type:none; > > > display:block; > > > margin:0; > > > padding:2px; > > > height:32px; > > > cursor:pointer;} > > > > </style> > > > </head> > > > <body> > > > <label for="input">Autotext:</label> > > > <input type="text" id="input" name="input" size="15" /> > > > <div id="results" class="autocomplete" style="display: none; > > > position:relative;"></div> > > > <script type="text/javascript"> > > > var txtid = 'input'; > > > var divid = 'results'; > > > var server = 'http://localhost:8080/ewcmtestbed/autocomplete'; > > > new Ajax.Autocompleter(txtid, divid, server, { tokens: ','}); > > > </script> > > > </body> > > > </html> > > > > The error: > > > In prototype.js > > > element is null > > > > The method: > > > cleanWhitespace: function(element) { > > > element = $(element); > > > var node = element.firstChild; > > > while (node) { > > > var nextNode = node.nextSibling; > > > if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) > > > element.removeChild(node); > > > node = nextNode; > > > } > > > return element; > > > }, -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.