views:

172

answers:

1

Hello

I have an error that occurs in a specific event handler that I setup using jQuery and the code just breaks without any errors being displayed. When I used to code similar things in YUI I would setup YAHOO.util.Event.throwErrors = true; in my dev. version and that was telling YUI's event handler to throw errors. I can't find anything similar, is it just me being blind and not seeing it ?

Thanks!

Here's an example...

<html>
<head>
<title>jQuery Events</title>
</head>
<script src="https://www.google.com/jsapi"&gt;&lt;/script&gt;
<script>
google.load('jquery', '1.3.2');
</script>
<body>
<p>click me</p>
<script type="text/javascript">
    $(document).ready(function() {
        $("p").click(function() {
            console.log('How to display an error here similar to the native onclick ?');
            qaz;
            console.log('this line is not executed because of the error, but the error is not reported. Is there a way to have jQuery report those errors ?');
        });
    });
</script>
</body>
</html>
+1  A: 

I'm pretty certain that jQuery won't swallow errors for you, so you should definitely be seeing the error from your undefined qaz.

Running your updated page, I still see both the console.log and the error on the undefined qaz in Firebug. Opening up the normal browser error console, I also see the qaz is not defined (...temp.html - Line: 15) message there too. In IE, I of course get "console" is undefined, but that just shows that errors are getting through there as well (since there's no console). Assuming you're running that exact same piece of html/js, there's obviously some other variable in play that is causing issues for you.

What version of Firebug are you running? I had various random issues with debugging javascript & the like with version 1.4.x, but 1.5.0 seems much more consistent and stable.

Alconja
I was using Firebug 1.5 but after reading what you said I thought I'd check for updates and updated from FF 3.5.7 to 3.6 and sure enough the error does show up now (and also in the real application where I first saw this)I am 100% sure it wasn't yesterday, so something must have been hung on my machine, and it's not FF 3.5.7 cos I just tried it on a VM now and I get the correct behavior.I got confused because I used to use YUI and it will swallow up errors in many event handlers unless you set it to not do that.thanks!
SBUJOLD