I'd like to access a class above the one that is accessible via "this". Is there something like PHP's "parent::"?
I use the "Prototype"-JS-Lib, just to make my example code more understandable...
I'll post some code to explain my problem:
Code:
var comments = {
isFormOk: function()
{
progressIndicator('comment-sent', {status: 'load'});
var elementsFail = checkUserData(['title', 'desc', 'mail'], '');
elementsFail.each(function(element) {
$('l' + element).setStyle({color: 'rgb(255, 0, 0)'});
});
if (!elementsFail.length)
{
progressIndicator('comment-sent', {status: 'none'});
return true;
}
else
{
progressIndicator('comment-sent', {status: 'fail'});
return false;
}
},
sendComment: function()
{
if (this.isFormOk())
{
instance = this;
$('comment').request(
{
parameters: {title: $F('title'), desc: $F('desc'), mail: $F('mail'), name: $F('name')},
encoding: 'utf-8',
onSuccess: function(response)
{
this.isServerScriptOk(response); //at this point I'd like to call isServerScriptOk() function, which is one level above (?)...
},
onFailure: function()
{
progressIndicator('comment-sent', {status: 'fail'});
},
onCreate: function()
{
progressIndicator('comment-sent', {status: 'load'});
writeUserData(['name', 'mail']);
}
});
}
},
isServerScriptOk: function(response)
{
if(response.responseText)
{
progressIndicator('comment-sent', {status: 'ok'});
}
else
{
progressIndicator('comment-sent', {status: 'fail'});
}
},
toggleNewComment: function()
{
Effect.toggle('newcomment', 'slide', {beforeStart: function() {
insertUserData(readUserData(['name', 'mail']));
}});
}
}
Hoping for many useful answers ...
Many thanks in advance!
|