|
|
|
Tómas Guðmundsson
|
Some javascript/style in this post has been disabled (why?)
Hi all. Let me start by saying that I have, cleared my
cache and private settings, restarted Firefox, restarted MapGuide and restarted
my computer in order to get the newest version of my file to work, but all I
needed after a single change is a refresh (to a .js file). Now, I have this
function that is similar to the ones in Legend so maybe someone can just point
real quick and tell me, here you go. But there is something I don‘t know
why is happening but I keep getting „testFunction() is not a function“
when it get‘s called from only one function. This is my function: testFunction : function() { console.log('not working idiot, what are
you doing wrong!'); }, Here are two function calling it. contentLoaded : function(response) { this.domObj.innerHTML =
response.responseText; this.appendLayerSwitch(); this.testFunction(); }, handleClick : function(layer) { var startGroup = map.layerRoot; if (!this.showMapFolder) { startGroup =
map.layerRoot.groups[0]; } this.testFunction(); // * for(var i=0;
i<startGroup.groups.length; i++) { this.handleClick(layer); // ** } }, In the handleClick function I get errors for both
(*) and (**) and I don‘t know why. Maybe I can]t see my error
because I’m really, really tired after this weekend so any help is
appreciated. I’ve even tried rewriting all functions. Regards Tómas _______________________________________________ fusion-users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/fusion-users |
|
Chris Claydon
|
Some javascript/style in this post has been disabled (why?)
Hi Tómas, Do you have Firefox and Firebug
installed? They make it easy to track down issues such as this one. In this
case, you’ve set up the binding to the handleGroups function using this
code:
Event.observe(input, 'click', this.handleGroups.bind('gotur',null)); If you put a breakpoint in
Firebug inside the handleGroups function, you’ll see that the ‘this’
object points to the string ‘gotur’, so it is not possible to call
this.testFunction(). If you change the line above to
read:
Event.observe(input, 'click', this.handleGroups.bind(this,null)); Then it should be possible to
call this.testFunction() from within the handleGroups function. I hope that helps, Chris. From: Tómas Guðmundsson
[mailto:[hidden email]] Yeah sure. /** *
Fusion.Widget.InformationPanel */ /***************************************************************************** * Class: Fusion.Widget.InformationPanel * © Snertill ehf. * Author : Tomas
Gudmundsson * Date: 2008/06/02 * A widget to display
information. ****************************************************************************/ Fusion.Widget.Information =
Class.create(); Fusion.Widget.Information.prototype
= { map : null, initialize :
function(widgetTag) {
Object.inheritFrom(this, Fusion.Widget.prototype, [widgetTag, false]);
//console.log('InformationPanel.initialize');
var json = widgetTag.extension;
//console.log(widgetTag);
var source = '../../../widgets/php/InformationPanel.php';
var a = new Ajax.Request( source, Object.extend({
method:'get',
onSuccess: this.contentLoaded.bind(this) }));
//this.domObj.innerHTML = a.transport.responseText;
//this.domObj.appendChild(a.respon);
map = this.getMap(); }, contentLoaded
: function(response) {
this.domObj.innerHTML = response.responseText;
this.appendLayerSwitch(); },
appendLayerSwitch : function() {
var input,span,div;
div =
document.createElement('div');
span =
document.createElement('span');
input =
document.createElement('input');
div.setAttribute('class','layerSwitch');
span.setAttribute('id','layerSwitchText');
span.innerHTML = 'Layer On/Off';
input.setAttribute('type','checkbox');
input.setAttribute('name','chbLayerOnOff');
Event.observe(input, 'click', this.handleGroups.bind('gotur',null));
div.appendChild(input);
div.appendChild(span);
this.domObj.appendChild(div); }, handleGroups
: function (group, layerName) {
console.log(group);
console.log(layerName);
this.testFunction(); },
processGroups: function (group, layerName) {
var startGroup = map.layerRoot;
if (group != null) {
startGroup = group;
}
this.testFunction();
for(var i =0; i < startGroup.groups.length; i++) {
this.processGroups(startGroup.groups[i]);
}
for(var i = 0; i < startGroup.layers.length; i++) {
if (startGroup.layers[i].name == layerName) {
if (startGroup.layers[i].visible == true) {
startGroup.layers[i].hide();
} else {
startGroup.layers[i].show();
}
}
} }, testFunction
: function() {
console.log('not working idiot, what are you doing wrong!'); }, /* a way to get some layers
and turning them on or off.
if(this.map.getActiveLayer()) {
console.log(this.map.getActiveLayer().name);
this.map.getActiveLayer().hide(); } var
startGroup = this.map.layerRoot; if
(!this.showMapFolder) {
startGroup = this.map.layerRoot.groups[0]; }
console.log(startGroup.groups.length); for (var i=0;
i<startGroup.layers.length; i++) {
console.log(startGroup.groups.name); } */ }; From: Chris Claydon
[mailto:[hidden email]] Are all these methods defined
inside the same prototype class definition? Can you send out the content for
the whole file, to put these methods in context? From:
[hidden email]
[mailto:[hidden email]] On Behalf Of Tómas
Guðmundsson Hi all. Let me start by saying that I have, cleared my
cache and private settings, restarted Firefox, restarted MapGuide and restarted
my computer in order to get the newest version of my file to work, but all I
needed after a single change is a refresh (to a .js file). Now, I have this
function that is similar to the ones in Legend so maybe someone can just point
real quick and tell me, here you go. But there is something I don‘t
know why is happening but I keep getting „testFunction() is not a
function“ when it get‘s called from only one function. This is my function: testFunction : function() {
console.log('not working idiot, what are you doing wrong!'); }, Here are two function calling it. contentLoaded :
function(response) {
this.domObj.innerHTML = response.responseText;
this.appendLayerSwitch();
this.testFunction(); }, handleClick :
function(layer) { var
startGroup = map.layerRoot; if
(!this.showMapFolder) {
startGroup = map.layerRoot.groups[0]; }
this.testFunction(); // *
for(var i=0; i<startGroup.groups.length; i++) {
this.handleClick(layer); // ** } }, In the handleClick function I get errors for both
(*) and (**) and I don‘t know why. Maybe I can]t see my error
because I’m really, really tired after this weekend so any help is
appreciated. I’ve even tried rewriting all functions. Regards Tómas _______________________________________________ fusion-users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/fusion-users |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |