Autocompleter does not work in FireFox 3.5.5

4 views
Skip to first unread message

mjk

unread,
Dec 11, 2009, 10:10:42 AM12/11/09
to Prototype & script.aculo.us
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;
},

T.J. Crowder

unread,
Dec 11, 2009, 11:02:39 AM12/11/09
to Prototype & script.aculo.us
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 / com
www.crowdersoftware.com

joe t.

unread,
Dec 11, 2009, 9:00:55 PM12/11/09
to Prototype & script.aculo.us
> 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.

T.J. Crowder

unread,
Dec 12, 2009, 6:05:23 AM12/12/09
to Prototype & script.aculo.us
> 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.

joe t.

unread,
Dec 12, 2009, 8:49:42 PM12/12/09
to Prototype & script.aculo.us
Uhhhh, right, sure, yeah, of COURSE i saw that... (didn't).

i tend to agree with you on [not] placing the active script block at
the end of the document and trusting it to work 100% of the time. Like
you, i haven't seen any hard data on why NOT to, but just don't fully
trust it.

i don't see any obvious reason the script would be failing. Tracing
back #clearWhitespace from Prototype, it only occurs in Autocompleter
in the #onComplete callback. i don't use the class that much, so i'm
not the best one to ask. i just happened across your initial response
in my digest email. :O

Sorry i couldn't be more help on this one.
-joe t.

Alex McAuley

unread,
Dec 13, 2009, 4:42:02 PM12/13/09
to prototype-s...@googlegroups.com
Everyone seems to have missed a solid point on this ...


The scripts are loded localhost:4402

and the server= localhost:8080

Thats an XDR as the ports differ ...

Perhaps 3.5.5 has some different security protocol in place that wont allow
it but earlier did



Alex Mcauley
http://www.thevacancymarket.com
--

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-s...@googlegroups.com.
To unsubscribe from this group, send email to
prototype-scripta...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Reply all
Reply to author
Forward
0 new messages