[Dojo-interest] Need help in understanding what's going on

Peter Higgins dante at dojotoolkit.org
Wed Jun 23 12:23:53 EDT 2010


You just need to wire two bits of things together here. You have the 
onClick function working, you get the item. I presume this data item 
contains some information about where you want to pull content from. a 
url, perhaps. I think it's a dojo.data item (I don't use tree, much :) )

var myTreeOnClickHandlerThinger = function(item){
       setMyContentPaneToSomething(item.getAttribute("url")); // it is 
getAttribute right?
}

var setMyContentPaneToSomething = function(url){
       var myContentPane = dijit.byId("whatever");
       myContentPane.attr("href", url); // in 1.5 will be .set("href", url)
}

It is intentionally verbose/broken out because you will invariably need 
it to be more complex. Maybe the data item has the full content to place 
in it. maybe it has a special member indicating you should generate a 
special url to hit.

You could do it all in the Tree creation too

new dijit.Tree({

       onClick: function(item){
             dijit.byId("mypane").attr("href", item.getAttribute("url"));
       }

    ...blah

}, area);

but that could end up being fragile and difficult to maintain.

If you are seeing [object Object] when you are trying to inspect an 
object you must be using alert() or trying to dump it to html. You 
should get a debugger and console.log(item) to inspect. Firebug, Firebug 
Lite, and most all the major browsers have _some_ way of handling at 
least simple inspection.

Hope this helps.

~phiggins

Harry Devine wrote:
> OK, so I have a page set up where it is patterned after the Mail example 
> (accordian pane on the left, and a content pane on the right).  On the 
> accordian pane, I have some items in a tree that I load from a json 
> file.  What I want to do is click on one of the items from the tree, 
> figure out what was picked, and load some content based on that into the 
> right-hand content pane.
>
> I know how catch the onClick method of the tree.  What I'm having 
> trouble wrapping my head around is how to generate the content on the 
> right-hand content pane.  In the mail example, it is all done via a 
> large json file.  I understand the concept presented there, but its sort 
> of a "smoke and mirrors" thing to me.  Not a knock on it or anything, as 
> its a great showing of Dojo IMO.  Just saying that, for me, its not that 
> practical to understand and apply in my case.
>
> So, how do I: 1) determine what item was clicked in the tree? The json 
> file has an id parameter with each item, but so far I can only see 
> [object Object] when I try and print out what was clicked.  2) Is the 
> right-hand content pane suitable for the dynamic content that I'm 
> looking to generate?  Should I be using something else?  Perhaps an 
> iFrame (which I've never really used before)?
>
> Thanks for any help.  I can provide my code if anyone thinks it will 
> help understand what I have and what I'm trying to accomplish.
> Harry
>
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://docs.dojocampus.org
> Dojo-interest at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>   



More information about the Dojo-interest mailing list