问题
I am trying to open a floating panel, using onClick event, it opens fine but shows this error in the console, this.onClick is not a function
.
If I close the floating panel and then try to a reopen, it won't open again and I keep receiving the same error in the console.
This is my application. You can see a floating panel emerge when you click on the Layers
button in the toolbar.
This is the main function that is opening the FLoating Panel,
function addFloatingPanel() {
var fp = new dojox.layout.FloatingPane({
title: "Layers",
resizeable: true,
dockable: false,
closable: true,
style: "position:absolute; top:0; left:50px; width:245px; height: 175px; z-index: 100; visibility: hidden;",
id: 'floater'
}, dojo.byId('floater'));
fp.startup();
if (dojo.byId('floater').style.visibility === 'hidden') {
dijit.byId('floater').show();
} else {
dojo.byId('floater').style.visibility = 'hidden'
dijit.byId('floater').show();
}
}
Where am I going wrong? Also, the floating panel is visible in firefox but not in chrome!!
回答1:
Needed to create the dojo.connect
function
<div data-dojo-type="dijit.form.Button" id="searchTool" >Search</div>
for onclick
event,
searchTl = dojo.byId('searchTool');
dojo.connect(searchTl, "onclick", openSrFp);
and add this function,
var fp = dojo.byId('floater');
if (fp.style.visibility=="hidden") {
fp.style.visibility="";
} else {
fp.style.visibility="hidden";
}
来源:https://stackoverflow.com/questions/12548488/unable-to-close-and-reopen-floating-panel-in-dojox