Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How to Debug Widgets?

How to Debug Widgets?
Thread Tools
Arkham_c
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
May 24, 2005, 03:03 PM
 
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
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 24, 2005, 03:22 PM
 
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'."
     
Arkham_c  (op)
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
May 26, 2005, 01:15 AM
 
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
     
Big Mac
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status: Offline
Reply With Quote
May 26, 2005, 03:01 AM
 
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
     
registered_user
Dedicated MacNNer
Join Date: Nov 2001
Location: Are Eye
Status: Offline
Reply With Quote
May 30, 2005, 10:05 AM
 
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.
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 09:46 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,