Dojo/Firebug question

How to set a breakpoint in a dojo loaded script

Page 1 of 1

6 Replies - 2306 Views - Last Post: 21 October 2009 - 07:19 AM

#1 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Dojo/Firebug question

Posted 19 October 2009 - 10:49 PM

So dojo is nice since it lets you just add: dojo.require("mypackage.mywidget") into your code and it will go out and load the javascript for <whatever>/mypackage/mywidget.js

Thats great... but that does not come up under firebug's list of scripts... So how do you set a breakpoint in one of these javascript files?

I suspect that the only way to is crawl along the DOM and find the widget node... but that gets you the object, how do you go from object to code that defines it... I just know I *must* be making this more complicated than it has to be.

Also: is there a good Firebug tutorial/reference out there? I *think* it is capable of more than I currently do with it and it would be nice to be able to look over something rather than having to dig into it (which I really don't have time for presently).

Is This A Good Question/Topic? 0
  • +

Replies To: Dojo/Firebug question

#2 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: Dojo/Firebug question

Posted 20 October 2009 - 02:36 AM

This thread made me check out the firebug website. I now know that you can write to firebug's console from anywhere in your javascript app really easily:
console.log("hello world");



http://getfirebug.com/logging.html
Was This Post Helpful? 0
  • +
  • -

#3 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: Dojo/Firebug question

Posted 20 October 2009 - 03:34 AM

Firebug for IE!!
Was This Post Helpful? 0
  • +
  • -

#4 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Dojo/Firebug question

Posted 20 October 2009 - 10:35 AM

Yea Firebug lite is pretty awesome.

I still have not figured out how to debug the dojo scripts... I kind of think that maybe you can't... When you pull up the script for the eval() line you DO get to the script from the js file! Awesome right? Should be able to set my breakpoints from there... but sadly no, because at that point the whole file is just 1 line (and breakpoints are done per-line).

So in the end I guess injecting console.log/console.info/console.warn/console.error lines is the only way to go (the console.error is actually extra useful because it gives you a kind of stack trace for the debugging line!)

There are a couple of tutorials on firebug but they are pretty basic. There are scattered blogs that go into a little more detail but I have a feeling that people have not really scratched the surface of what firebug is capable of.
Was This Post Helpful? 0
  • +
  • -

#5 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Dojo/Firebug question

Posted 20 October 2009 - 11:30 AM

just come FYI on this:

Using firebug you can use: debug(fn) to set a breakpoints on the first line of a particular function.

My problem is that I seem unable to select the object that I want. I don't really know why but if I pick a particular DIV and do:
$('div_id') -- returns null
so I did an inspect element and right click to "Copy XPath" then tried:

$x('pasted-xpath') returned an empty array...

So for some reason I can't get at those nodes in the DOM... I *think* there may be some proprietary little tweak being used to block the firebug console... or it could be that I am still missing something.
Was This Post Helpful? 0
  • +
  • -

#6 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Dojo/Firebug question

Posted 20 October 2009 - 12:02 PM

IF you use the object inspector in Firebug, then you select the object you want to inspect -- then in the console you can use $1 to get the currently selected element. :) getting there... all I need to do is get the dojo object and I will be able to get where I need to go.... I hope...
Was This Post Helpful? 0
  • +
  • -

#7 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Dojo/Firebug question

Posted 21 October 2009 - 07:19 AM

ALRIGHT!!!

Ok... so Firebug offers a command to help change the scope of the console: cd(window)

The problem is this is not terribly easy to use. The syntax that seemed to work for me was:

cd(frames['frameName'])

Once I was here I was able to use the dojo object to do my dirty work and set my break point and do what needed to be done.

actually no... the debug(fn) line did not help... I am sure it set a breakpoint, but none one that helped me.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1