Solved

prototype.js: $F(foo) = "element has no properties" -- but which element?

Posted on 2006-06-16
5
584 Views
Last Modified: 2010-08-05
I'm getting an "element has no properties" on line 1276 of prototype.js, which is almost certainly a result of a call I'm making in the $F('fieldname') syntax.  I know what usually causes this-- misspellings of 'fieldname', or neglecting the quotes around it if it's a string literal.  Generally an easy fix.

Thing is, I've just connected many, many untested functions with many, many instances of $F('whatever').  Looking through them is excrutiating, and breaking apart the functions to test them individually is not a desirable solution.  Is there a way to toss in some error-handling or event-logging that'll give me a better idea about what attempted element is failing?
0
Comment
Question by:Rakafkaven
  • 4
5 Comments
 
LVL 4

Author Comment

by:Rakafkaven
ID: 16924357
I just tried one thing-- inserting this line right above 1276:

$(temporaryfield).value = element.id;

This means that when the error hits,temporaryfield holds the id of the last element that was successfully parsed, which does narrow it down somewhat.  Still not a great solution.
0
 
LVL 4

Author Comment

by:Rakafkaven
ID: 16924372
Changing that line to:

$(temporaryfield).value = $(temporaryfield).value + "," + element.id;

...gives me a full log of successful parses, which should let me track down the culprit.  But if there's a way to return the line number or attempted-element name or any other more graceful approach, I'll be glad to award points for it.
0
 
LVL 4

Author Comment

by:Rakafkaven
ID: 16924628
Hey, mozilla has a built-in debugger.  Fancy that.  A little RSI with the "Step Into", and there I see where I tried to pass an entire array to my $F(whatever), rather than a single array element.  That helps some.
0
 
LVL 4

Author Comment

by:Rakafkaven
ID: 16924688
Well, I don't usually answer my own questions THAT quickly.  So... uh... tell me something interesting about debugging.  Seems a shame to let perfectly good points go to waste.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 16926580
My first step in such situations is to disable the onLoad handlers by commenting them out //
Then I look for simple syntax errors. Most runtime errors are rooted in tricky syntax errors which are overloaded at starting some undefined functions whose definition lacks on syntax follow up errors.
When I get that far I spot some simple alerts(1), alert(2) at spots outside of any function or statement block. If the alerts do not occur in the order I expect, then I know that interpreter is scanning my source in some other way then I see it. Most again because of missing closing or opening curly braces. When the alerts then come in desirable order, then I know at least we see the same functions and then first I start debug function, most with alerts and seldom with debugger.


0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now