dojo.widget.manager.getWidgetById() fails because the widget has not
been created yet.  Manually adding an element to the DOM with the
"dojoType" attribute does not automically force DOJO to add that
element to the current list of widgets.  The reason it is added
automatically when you have it coded into the HTML is because DOJO
parses the DOM onload, looking to add any widgets that it finds.  Try
this:

Make sure the DOM element you are creating has it's ID set (in this
case i'll use 'firstTree')

dojo.widget.createWidget('firstTree');

This will tell DOJO to locate this DOM element and initialize it as a
widget.  Now this should work:

dojo.widget.byId('firstTree');

This is short-hand notation for
dojo.widget.manager.getWidgetById('firstTree')

HTH,
scott

fgrim wrote:
> Howdy List,
>    So I am using MochiKit in concert with dojo and seeing some weird
> behavior.  If I build out a div with MochiKit.DOM>DIV({}) and append it
> to an existing DOM element on the page like so:
>
> var root = MochiKit.DOM.DIV({ 'dojoType':'Tree',
> 'menu':'treeContextMenu',
>                               'DNDMode':'between', 'selector':'treeSelector',
> 'actionsDisabled':'addChild',
>                               'toggler':'fade', 'widgetId':'firstTree',
>                               'controller':'treeController'}, 
> this.BuildMenu(menu_data));
> MochiKit.DOM.swapDOM('dummy', root);
>
> and the immediantly after call:
>
>       var firstTree = dojo.widget.manager.getWidgetById('firstTree');
>       for(eventName in firstTree.eventNames) {
>               dojo.event.topic.subscribe(
>                       firstTree.eventNames[eventName],
>                       new reporter('firstTree'),
>                       'go'
>               );
>       }
>  firstTree is undefined.  But if I put the same html in the page
> statically firstPage is defined.  What am I missing?
> 
> Fred


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to