amd code for floatingpane and dock...

907
6
Jump to solution
10-17-2013 12:55 PM
KenMorefield
Occasional Contributor
Hi,
I'm working on creating a template based on the "new" AMD style of coding.  Does anyone have some functioning code for how to create a dojox/layout/FloatingPane that will "dock" to a dojox/layout/Dock?  I can't find any functioning examples written in AMD whether it be ESRI samples or dojo ones.  I had this functionality working just fine in my older legacy apps...

Thanks,
Ken
0 Kudos
1 Solution

Accepted Solutions
BenFousek
Occasional Contributor III
0 Kudos
6 Replies
KenMorefield
Occasional Contributor
Anybody?  The part I'm struggling with is how to attach the Floating Pane to the dock in AMD.  Can't quite figure out how to call everthing properly...

Ken
0 Kudos
BenFousek
Occasional Contributor III
Here's the basics.

require([
 //layout x
 'dojox/layout/FloatingPane',
 'dojox/layout/Dock',
  //dojo
 'dojo/dom-construct',
 'dojo/_base/window',
], function (
  //layout x
  FloatingPane, Dock,
  //dojo
  domConstruct, win
) {
  var dock = new Dock({
    style: 'position:absolute;bottom:0;right:0;height:0px;width:0px display:none;z-index:0;'
  }, domConstruct.create('div', null, win.body()));

  //measure floating pane
  var measurefp = new FloatingPane({
    id: 'measure-floating-pane',
    title: 'Measure',
    resizable: false,
    resizeAxis: null,
    closable: false,
    dockable: true,
    dockTo: dock,
    style: 'position:absolute;top:80px;left:320px;width:220px;height:200px;visibility:hidden;overflow:hidden;',
    href: 'html/measure.html',
    preventCache: true,
    preload: false
  }, domConstruct.create('div', null, win.body()));
  measurefp.startup();
  measurefp.on('focus', function () {
    measurefp.bringToTop();
  });
  measurefp.on('show', function () {
    measurefp.bringToTop();
  });

});


The difference with AMD is you need to require dojox/layout/Dock to use it in the function as a variable. In legacy and AMD the dock is required by the floating pane class. You can still create a new dock with var dock = new dojox.layout.Dock() in AMD, but that kinda defeats the point.
KenMorefield
Occasional Contributor
Hi Ben,
Thanks so much for the pointers!  Would it be possible for you to post a full sample with the html included... Maybe a simple basemap, with a dockable floating pane? 

Thanks a bunch for bearing with my Newbie-ness!

Ken
0 Kudos
BenFousek
Occasional Contributor III
0 Kudos
KenMorefield
Occasional Contributor
Check this https://github.com/btfou/simple-measure


Thanks Ben - the sample helps an awful lot!

Ken
0 Kudos
AdrianMarsden
Occasional Contributor III

ok - old thread and the Git example is long gone, and I've got everything "working" but I do get this error on "closing" the pane (really hiding it) 

TypeError: Cannot read property 'addNode' of undefined
 at Object._dock (js.arcgis.com/3.23/dojox/layout/FloatingPane.js:10)
 at js.arcgis.com/3.23/init.js:63
 at Object.<anonymous> (js.arcgis.com/3.23/dojox/layout/FloatingPane.js:8)
 at d.Animation.onEnd (js.arcgis.com/3.23/init.js:63)
 at d.Animation._fire (js.arcgis.com/3.23/init.js:248)
 at d.Animation._cycle (js.arcgis.com/3.23/init.js:251)
 at Object.<anonymous> (js.arcgis.com/3.23/init.js:63)
 at Object.c [as run] (js.arcgis.com/3.23/init.js:119)
 at js.arcgis.com/3.23/init.js:63

But many thanks for the earlier post.

0 Kudos