Hi Neil, really this was the problem, the list was empty, so no item at
the index...
I switched back to appendItem and worked fine, but for some reason the
"random list order" problem remains.
I will try the Michael solution and use a normal for instead of for in
to see if it fix the "random list order" problem...
Thanks Neil and Michael for the much appreciated help!
--
Renato Rodrigues
http://www.renatorodrigues.com
Neil wrote:
Michael Vincent van Rantwijk wrote:
Renato R. (RRaver) wrote:
I'm trying to populate a listbox with some stored preferences but it
doesn't work if I use inserItemAt only if I use appendItem, but
appendItem is giving me a unordered list that changes its order
everytime it is populated, so I decided to use insertItemAt...
The code I am using is something like this...
var signatures =
prefService.getBranch("").getChildList("myExt.signatures", {});
for (var i in signatures) {
signaturesList.insertItemAt(i,
myPref.getCharPref(signatures[i]) );
}
and the error is
Error: uncaught exception: [Exception... "Component returned failure
code: 0x80004005 (NS_ERROR_FAILURE)
[nsIListBoxObject.getItemAtIndex]" nsresult: "0x80004005
(NS_ERROR_FAILURE)" location: "JS frame ::
chrome://global/content/bindings/listbox.xml :: getItemAtIndex ::
line 481" data: no]
getItemAtIndex is called from method inserItemAt in listbox.xml and
your problem here is, most likely, an index (i) problem. Add a
dump("\ni:" + i); to check the index, and be surprised, or change this
line:
-for (var i in signatures) {
+for (var i=0; i < signatures.length; i++) {
And you'll need to switch back to appendItem because insertItemAtIndex
only works if there is already an item at that index.
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners
|
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners