|
|
How to Debug Widgets?
|
|
|
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
I have a widget I am developing. It's driving me crazy though. I click the button, which has an onClick event, and nothing happens! No error, no feedback, nothing.
How can I get some sort of feedback on what's going wrong? I can't even do print statements as far as I can tell, and alert() doesn't work within the context of the Dashboard.
Here's what I am doing:
Code:
function doSearch(search_string)
{
document.getElementById("searchResults").innerHTML = search_string;
}
and
Code:
<div id="front">
<span id="searchForm">
<form name="SForm" action="">
<p>
<br/>
Look For: <input id="searchField" type="search" size="25" value="ABC XYZ">
<br/>
<input type="button" class="button" name="SearchButton" value="Search" onclick="doSearch(searchField.value);">
</p>
</form>
<span id="searchResults">Enter a search and hit "search"</span>
</div>
Shouldn't this work? It's like the doSearch method is never called.
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
I don't know if this is related to your problem, but you're never terminating your input tags. I suppose it's possible that's confusing the DOM.
Also, I don't think you can just do doSearch(searchField.value). I think it would need to be doSearch(document.getElementById("searchField").va lue). My JavaScript is a wee bit rusty, but that's my recollection of how it works.
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
Well, it turned out that my code was working. I logged out and back in and the widget works.
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status:
Offline
|
|
You may still want to take a look at this tech note on debugging widgets.
|
"The natural progress of things is for liberty to yield and government to gain ground." TJ
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Nov 2001
Location: Are Eye
Status:
Offline
|
|
If you open up the Console, it'll put all the error messages and alerts to the console log.
It's a real handy means to see what's going on with the widget, even if it's not always the most descriptive error message.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|