Reputation: 491
I know this could be similiar with someone, but i'm sure, i'm not yet found the answer here, i just want to call an anonymous function in a variable, which like this
me.req.ref['index']['index'] = function() {
var a, mount;
return {
function: function(fout) {
mount = new loading(fout, "flogin");
mount.start("Login granted, redirecting..");
a = setTimeout(function() {
window.location.href = purl+"profile";
}, 1000);
}
}
};
and i want to call it like this.
var ret;
ret = new me.req.ref[refcode][resp];
ret.function(fout);
but it show an error.
Uncaught TypeError: ret is not a function
i implement this in method loading()
and work well, here the code.
function loading(e, code) {
var x = 0;
return {
start: function(str) {
var dot, y;
dot = [".","..","...","...."];
y = 0;
e.style.height = "auto";
e.style.maxHeight = "100%";
e.innerHTML = str+dot[y]+" ("+x+")";
me.time.mount[code] = setInterval(function() {
e.innerHTML = str+dot[y]+" ("+x+")";
x++; y++;
if(y>3) {
y = 0;
}
}, 1000);
},
stop: function() {
clearInterval(me.time.mount[code]);
}
}
}
the way that i call loading()
is like this.
mount = new loading(fout, me.time.code["flogin"]);
mount.start("string"); // if i want to start an loading.
mount.stop(); // if i want to shutdown the loading.
any solution? please help. thanks for any correction.
Upvotes: 1
Views: 195
Reputation: 491
Alright, the problem in here is calling the method like this ret().function(fout)
, when the ret
is an Object
, so this problem answered, to call the function i need to write it like this ret.function(fout)
.
Upvotes: 1