Page 1 of 1

Cant reach an object after I created it..

Posted: Wed Apr 03, 2013 6:44 pm
by Bee Sprout

Cant reach an object after I created it..

I created this object withing a function, I need to run the hangup(); function on another button, but cant reach it. Any Ideas?
function makecall()
{
var dial_num = Tiggzi('numberToDial').text();
//alert(dial_num);
Tiggzi('numberToDial').text("Dialing... " + dial_num);
phono.phone.dial(dial_num, {
onRing: function() {
Tiggzi('numberToDial').text("Ringing... " + dial_num);
},
onAnswer: function() {
Tiggzi('numberToDial').text("Answered");
},
onHangup: function() {
Tiggzi('numberToDial').text("Ready");
}
});
}


Cant reach an object after I created it..

Posted: Wed Apr 03, 2013 7:18 pm
by maxkatz

The inner function is not visible from the outside: https://developer.mozilla.org/en-US/d...


Cant reach an object after I created it..

Posted: Wed Apr 03, 2013 7:24 pm
by Maryna Brodina

Just to add:

Try to make the object global - declare the reference to the object through:

codewindow["objectName"] = {...};/code
not codevar objectName = {...} /code
Then you'll get an access to that object from any function through
codewindow["objectName"]/code


Cant reach an object after I created it..

Posted: Wed Apr 03, 2013 8:02 pm
by Bee Sprout

Sorry Marina, I am a rookie! This is my code I tried doing that still not working. Can you check i did right your advise?

// Checking call status, if answered do hangup on button press.
var input = Tiggzi('numberToDial').text();
var status = /Answered/;
var exists = status.test(input);
if(exists){
window["phono"].hangup();
alert("hangup presssed");
}else{
//var phono = $.phono({
window["phono"] = $.phono({
apiKey: "53468234589734258jjhklad55ab", //dummy key
onReady: function() {
//Tiggzi('numberToDial').text("Dialing...");
makecall();

Code: Select all

     } 

});

}

function makecall()
{
var dial_num = Tiggzi('numberToDial').text();
//alert(dial_num);
Tiggzi('numberToDial').text("Dialing... " + dial_num);
phono.phone.dial(dial_num, {
onRing: function() {
Tiggzi('numberToDial').text("Ringing... " + dial_num);
},
onAnswer: function() {
Tiggzi('numberToDial').text("Answered");
},
onHangup: function() {
Tiggzi('numberToDial').text("Ready");
}
});
}


Cant reach an object after I created it..

Posted: Wed Apr 03, 2013 8:44 pm
by Bee Sprout

Got it! Was able to solve it, thanks Marina! I owe you an Ice Cream Scoop!


Cant reach an object after I created it..

Posted: Wed Apr 03, 2013 8:48 pm
by Maryna Brodina

:) Glad you get it working!