Bee Sprout
Posts: 0
Joined: Wed Apr 03, 2013 6:44 pm

Cant reach an object after I created it..

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");
}
});
}

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Cant reach an object after I created it..

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Cant reach an object after I created it..

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

Bee Sprout
Posts: 0
Joined: Wed Apr 03, 2013 6:44 pm

Cant reach an object after I created it..

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");
}
});
}

Bee Sprout
Posts: 0
Joined: Wed Apr 03, 2013 6:44 pm

Cant reach an object after I created it..

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Cant reach an object after I created it..

:) Glad you get it working!

Return to “Issues”