@@ -286,9 +286,13 @@ define([ 'exports', 'jquery', 'underscore', 'widgy.backbone', 'lib/q', 'shelves/
286286 }
287287
288288 if ( this . canAcceptChild ( view ) ) {
289- $children . prepend ( this . createDropTarget ( view ) . el ) ;
289+ this . createDropTarget ( view ) . then ( function ( drop_target ) {
290+ $children . prepend ( drop_target . el ) ;
291+ } ) ;
290292 this . list . each ( function ( node_view ) {
291- var drop_target = that . createDropTarget ( view ) . $el . insertAfter ( node_view . el ) ;
293+ that . createDropTarget ( view ) . then ( function ( that_drop_target ) {
294+ var drop_target = that_drop_target . $el . insertAfter ( node_view . el ) ;
295+ } )
292296 } , this ) ;
293297 this . refreshDropTargetVisibility ( ) ;
294298
@@ -331,7 +335,7 @@ define([ 'exports', 'jquery', 'underscore', 'widgy.backbone', 'lib/q', 'shelves/
331335 }
332336 }
333337
334- return drop_target . render ( ) ;
338+ return drop_target . renderPromise ( ) ;
335339 } ,
336340
337341 clearDropTargets : function ( ) {
@@ -442,11 +446,13 @@ define([ 'exports', 'jquery', 'underscore', 'widgy.backbone', 'lib/q', 'shelves/
442446 // this must happen after shelf.$el is in the dom so fixto can
443447 // find the .node element
444448 if ( this . isRootNode ( ) ) {
445- this . shelf . $el . fixTo ( '.node' , {
446- // mezzanine header
447- mind : '#container > .breadcrumbs, #container > #header' ,
448- // XXX: move this to css
449- zIndex : 50
449+ this . shelf . shelf_promise . then ( function ( shelf ) {
450+ shelf . $el . fixTo ( '.node' , {
451+ // mezzanine header
452+ mind : '#container > .breadcrumbs, #container > #header' ,
453+ // XXX: move this to css
454+ zIndex : 50
455+ } ) ;
450456 } ) ;
451457 }
452458 } ,
@@ -472,10 +478,15 @@ define([ 'exports', 'jquery', 'underscore', 'widgy.backbone', 'lib/q', 'shelves/
472478
473479 var shelf = this . shelf = this . makeShelf ( ) ;
474480
481+ var children = this . $children ;
482+
475483 this . listenTo ( shelf , 'startDrag' , this . startDrag )
476484 . listenTo ( shelf , 'stopDrag' , this . stopDrag ) ;
477485
478- this . $children . before ( shelf . render ( ) . el ) ;
486+ shelf . shelf_promise = shelf . renderPromise ( )
487+ shelf . shelf_promise . then ( function ( rendered_shelf ) {
488+ children . before ( rendered_shelf . el ) ;
489+ } ) ;
479490 return shelf ;
480491 } ,
481492
0 commit comments