Hello all,
I would like to have a floating pane, and if I close it, I want to be able to get it again. Here is what I mean,
function makeFloater() {
// programatically created FloatingPane with srcNode ref
var tmp = new dojox.layout.FloatingPane({
title: "dynamically created ...",
id:"floater3",
closeable:true,
resizable:true,
dockable: true
},"nonFloater");
tmp.startup();
}I am made into a FloatingPane in dojo.addOnLoad();
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In porta. Etiam mattis libero nec ante. Nam porta lacus eu ligula. Cras mauris. Suspendisse vel augue. Vivamus aliquam orci ut eros. Nunc eleifend sagittis turpis. purus purus in nibh. Phasellus in nunc.

I don't recall if
I don't recall if FloatingPane has a .destroyRecursive() or not, but have you considered creating the FP once, close it when you need to (sets display = none), when you are ready to display it again, set its content the way you want it, and just show it? Avoids the constant creation/destruction of the FP.
Yes, fwiw, .close()'ing a
Yes, fwiw, .close()'ing a dialog destroys it and it's children. hide()'ing a dialog simply "docks" it, which you can make invisible via css rules. then you can programatically show()/hide() or restore() the FloatingPane.
fp.hide();
fp.setContent("foo bar baz");
fp.show();
FloatingPane's container is a dojox.layout.ContentPane, so any of those methods will work.
Where in the script is the
Where in the script is the little x that closes the pane. I want to change that click funtion to somting else. I am not sure what is calling that function.
I see this,
I dont want to close, I want to change the css. I am not sure where this dojoattachpoint="closeNode" is.
Thanks for all the help,
timgerr
As always, there are several
As always, there are several ways to do what I think you want.
One way (if you will never use .close, aka, destroy):
dijit.byId('myFPid').close=function(){this.hide();}
Thereafter, clicking the x will just hide the FP, and you can .show it when you need to.
Thanks for the information
Thanks for the information but I was needing to find the function that closes the pane and change it to hide the pane. I am not sure where that code is withing the javascript.
Timgerr
Isn't that what the previous
Isn't that what the previous post did for you?
Sorry for not being more
Sorry for not being more specific, I was wondering what code I have to change I want to know what is closing to pane, what line of code. I am trying to learn what is happening so I can make the best changes for my situation.
I am looking for what is calling the close and when I find that I might be able to change it to use the dijit.byId('myFPid').close=function(){this.hide();}
I am learning this so I might not be explaining this correctly.
Thanks,
timgerr
Sorry, I didn't describe
Sorry, I didn't describe where you use the code I provided above. Just put it as the next line after you first create the floating pane, if creating the fp programmatically. If via markup, just put it in the function that your dojo.addOnLoad calls.
The earlier post you did, where it showed the closeNode, is where the onclick is being set to call close(). It is easier, I believe, to just do what I wrote above than to try to replace the closeNode's onclick. Could be wrong...
What my code above is doing is just "overriding" the "close" property/method of that instance of an fp. The function assigned to all fp instances' (without any overriding/extends) close method does three things (from memory): disconnects events, hides the fp, then destroys it, recursively. The above code replaces that with just the hide.
Alternatively, you could subclass the fp and modify the templateString to have onclick be assigned hide rather than close.
OK so I have been playing
OK so I have been playing around with this and working with test_FloatinPane.html
One(1) example is this
the last line before the close body tag I do this
dojo.addOnLoad(dijit.byId('floater1').hide());I want to not have this pane open when I get to the page. When I add that last line I get this error
dijit.byId("floater1") has no properties [Break on this error] dojo.addOnLoad(dijit.byId('floater1').hide());Why am I getting that error when It works fine when I press
hide first pane??Thanks for the help
timgerr
your addOnLoad function
your addOnLoad function needs to be a pointer to a function, not a function call() (with parenthesis, unless that call is returning a function. try:
[your stuff] dojo.addOnLoad(function(){ dijit.byId('floater1').hide(); });The Proper way to Destroy a previously created Floating Pane
This is not documented heavily, but after reviewing comments in the Dojo Source Code I determined the proper way to "kill" a previously instantiated object (widget) is thus:
if(thePane){ // Where thePane is the variable name of the previously instantiated Floating Pane thePane.destroyRecursive(true); // DestroyRecursive deletes the Pane and any Widgets contained by the pane }iirc, that is called anyway
iirc, that is called anyway when you thePane.destory() or thePane.close() (which calls thePane.destory(), which calls thePane.destroyRecursive())
not 100% on that though.
OK here is what I did,
OK here is what I did, around line 158 of FloatingPane.js I change
this.hide(dojo.hitch(this,"Destroy"));to
this.hide(dojo.hitch(this,"hide"));This will hide the pane instead of closing it.
Thanks for ALL!!!!! the help.
timgerr
Changing the source code
Changing the source code will work, but may present problems as you refresh the code with later dojo releases that may fix other things you care about.
You may want to revisit the simple one liner
dijit.byId('myFPid').close=function(){this.hide();}, since it should not interfere with new releases. It does the same replacement in your html file, not in the dojo source code, much easier for longer term maintenance. This method does require calling it on each FP id you want to behave this way. If you only have one or two FP ids, this is a good way to go.Or, if for some reason you don't like that method or have lots of FP ids to manage, another way to handle new releases pretty well, and not need to do the above for each instance of FP id in an html file is to use dojo.extend for the FP class. It will only be about 3-5 lines in your dojo.addOnLoad referenced function of your html file. If you have more than one or two FP ids, this is a good way to go.
Neither of the above methods changes the source code in the dojo distribution, which lets you do the inevitable dojo updates over time.
Thanks for the feed back.
Thanks for the feed back. Here is what I do not understad (because I have a little brain). I have this X that calles
this.hide(dojo.hitch(this,"Destroy"));How (what does the code look like) can I add thisdijit.byId('myFPid').close=function(){this.hide();},so when I click on the X the screen will be hidden?Thanks,
timgerr
Hi. What that statement
Hi. What that statement does is equivalent to what you were doing when you modified the source code. It is redefining (overriding) the default FloatingPane "close" function/method with a new function/method that does a "hide" instead. The equals sign is what redefines the "close" with the new function, which just calls the built-in "hide" function/method, instead. Therefore, since the FP connects the "X" onclick event to the FP "close" method, clicking the X calls the "close" method, which *now* calls "hide" instead of the other stuff it would normally do.
You would put the statement you questioned in the function your dojo.addOnLoad references.
However, if you want this change to apply to more than a specific FP or to all of them in a specific html page, use dojo.extend. What dojo.extend does is to do the same modification as described above, but to *all* FPs on that html page, thereby not needing to supply FP ids.
So, your choice is whether you want *all* FPs on a page to use the new "close" technique or just one/some of them.
Give it a try and see if it doesn't work exactly like you want it to. Both are really powerful techniques that you will find great uses for elsewhere in your applications. :)
As to where you would put
As to where you would put the code, more specifically, I assume you already have a dojo.addOnLoad statement that references a function that performs actions that can only be done once the html, DOM, and dojo have loaded, such as creating widgets programmatically, connecting events, etc. If not, you would create one. Sample below:
function init() { dijit.byId("myFPid").close = function(){ this.hide(); } } dojo.addOnLoad(init);Or (using dante's dojo.extend suggestion):
function init() { dojo.extend(dojox.layout.FloatingPane,{ close: function(){ this.hide(); } }); } dojo.addOnLoad(init);right. all floating panes:
right.
all floating panes: see other comment about dojo.extend(dojox.layout.FloatingPane,{});
some floating panes, create a subclass:
dojo.require("dojox.layout.FloatingPane"); dojo.declare("my.FloatingPane", dojox.layout.FloatingPane,{ // change just the close function of FloatingPane close: function(){ this.hide(); } });and use a dojoType="my.FloatingPane" (or new my.FloatingPane({},"someNode");) to create instances of your own FloatingPane with this special close method, still allowing you to make dojox.layout.FloatingPane's still ...
this is very easy to do if you are not using X-Domain build. If you are, your dojo.declare has to be inside a dojo.addOnLoad(function(){ }) to make sure dojox.layout.FloatingPane has loaded before you attempt to extend or subclass it.
Above are three very
Above are three very powerful methods of changing the behavior of a dijit widget, each only requiring a *very* few lines of code. This is one of the strengths of dojo. Once you are comfortable with them, you will find other uses for these techniques, without ever changing directly the dojo source code, thereby greatly easing dojo updates (bug fixes, enhancements, etc.). Enjoy!
one failsafe solution would
one failsafe solution would probably look like:
dojo.extend(dojox.layout.FloatingPane,{ close: function(){ this.hide(); } });ROCK ON, Thanks frankf and
ROCK ON, Thanks frankf and dante.
timgerr
does this solution go to far?
Hi. I'm very new to dojo and this post has helped me do what I'm trying to do, so thanks. However, it seems like this solution goes to far in overriding close method. That means that anything that calls the close method on the FloatingPane will actually end up hiding it. But there may be times when you really do want to close it. What we really need to override is the function that gets called when the user clicks the close button. Instead of calling this.close(), that method should call this.hide(). Unfortunately, since I'm such a newbie, I haven't been able to figure out how to do this. Anyone have any ideas? I've seen some reference in source to onCloseBoxClick, but I haven't been able to figure it out.
You can go into the source
You can go into the source .js file and change onclick=close to onclick=hide, but that presents a problem when you overwrite the .js file with dojo updates.
You can subclass, but then you have to remember to use the new class name.
Or you can
close: function(){ //changed from destroying to just hiding...
this.hide();
},
kill: function(){ //added (copy of old 'close') to permit an orderly destroy/kill...
// use: dijit.byId('myFPwidgetId').kill();
// summary: Close and destroy this widget
if(!this.closable){ return; }
dojo.unsubscribe(this._listener);
this.hide(dojo.hitch(this,"destroyRecursive",arguments));
}
});
I personally would use the latter, but everyone has different likes, dislikes, preferences.
Or you could probably do (note "hide" for the onclick event for the "closeNode" replaced "close")
templateString:"<div class=\"dojoxFloatingPane\" id=\"${id}\">\n\t<div tabindex=\"0\" waiRole=\"button\" class=\"dojoxFloatingPaneTitle\" dojoAttachPoint=\"focusNode\">\n\t\t<span dojoAttachPoint=\"closeNode\" dojoAttachEvent=\"onclick: hide\" class=\"dojoxFloatingCloseIcon\"></span>\n\t\t<span dojoAttachPoint=\"maxNode\" dojoAttachEvent=\"onclick: maximize\" class=\"dojoxFloatingMaximizeIcon\"></span>\n\t\t<span dojoAttachPoint=\"restoreNode\" dojoAttachEvent=\"onclick: _restore\" class=\"dojoxFloatingRestoreIcon\"></span>\t\n\t\t<span dojoAttachPoint=\"dockNode\" dojoAttachEvent=\"onclick: minimize\" class=\"dojoxFloatingMinimizeIcon\"></span>\n\t\t<span dojoAttachPoint=\"titleNode\" class=\"dijitInline dijitTitleNode\"></span>\n\t</div>\n\t<div dojoAttachPoint=\"canvas\" class=\"dojoxFloatingPaneCanvas\">\n\t\t<div dojoAttachPoint=\"containerNode\" waiRole=\"region\" tabindex=\"-1\" class=\"${contentClass}\">\n\t\t</div>\n\t\t<span dojoAttachPoint=\"resizeHandle\" class=\"dojoxFloatingResizeHandle\"></span>\n\t</div>\n</div>\n"
});
but that seems pretty messy... :)