Community Questions & Answers
variable must be remained during the life of the application
-**hello experts** I am trying to develop a titan android application, the application needs to be set only once after...
global variables
Hi, I have variables in app.js which are globals in all application in my iPhone App. When i try that with Android, my variables are not found. so how to make a variable visible in all the app ? thanks
Change label text to variable string problem
Hi guys, I can't seem to find the problem in this piece of code which should work 100% fine, but it does not. So I want to change the text of a label *(label.setText())*, but it does not seem to be able to **read the string value of the...
Variable Problem ?
Hi there, my alert doesn't work, i have missed something :( i can't find it :( what should i do? ~~~ var lat1; var lon1; var myLocation = function(latitude,longitude){ lat1 = latitude; lon1 =...
Mobileweb App get info from URL parameter?
I have a mobile web app, displayed in an IFRAME. I need to pass some data from a URL parameter in the IFRAME's SRC attribute, as in `src="/myapps/index.html?foo=bar` I could also put the app on the page itself, if the iframe is an issue, but I am...
commonJS & Global Variable Arrays module
Don't know how i can save a array instead of variables in commonJS module as described here: [commonJS & Global Variable](http://www.thewarpedcoder.net/2011/12/apccelrator-titanium-commonjs-global-variables) I tried the following code, but it doesn't...
How to change properties of a variable in a for loop
~~~ for (var i = 1; i < (x+1) ; i++){ var b = Titanium.UI.createButton({ width: bs, height: bs, id: "btn"+i, index: i, backgroundImage: "bBG"+i }); }; ~~~ This doesn't work. Also `backgroundImage: bBG+i` or...
How can i access a variable in an event on android?
Hi, what I want to do works fine with iPhone, but not with Android. I have to say that I'm not an JavaScript expert, may be I do some basic thing wrong. This is my code snippet of file DatasetListController.js: ~~~ function...
Write and read a variable in an includes js-file
Is it possible to write and read an variable in an includes js-file? I want to save some values in an global central file, for example the username, password, server-url, etc. which i want to use in different other files. I have this js-file to save my...
Passing array to new window
I am familiar with the concept of passing a variable to a new window by setting it as a window property. For example, if I have ~~~ var myText = 'hello'; var win2 = Ti.UI.createWindow({ // some parameters, customText: myText }); ~~~ And now I can...
Variable JSON parser
Is it possible to do something like that: ~~~ var VARIABLE = blablabla var table = Ti.UI.createTableView(tableViewOptions); var tableData = []; var xhr = Ti.Network.createHTTPClient({ onload: function() { // Ti.API.debug(this.responseText); ...
Global scope of variable
Hi I have two windows "win1" and "win2". I have declared a variable in win1 as `var patient;` the win2 has been created like this ~~~ var win2 = Ti.UI.createWindow({ url:'home.js' }); ~~~ the problem is I am not getting the value of...
runtime error : can't find variable "imageTaken"
how do i link variable from : ~~~ galleryImage.addEventListener('click', function(e) { Ti.Media.openPhotoGallery({ success : function(event) { var imageTaken = Ti.UI.createImageView({ // <<<<<this variable image : event.media, //...
a variable var
Why does this not work? I thought to give all the buttons a function with the `data.addEventListener` but that doesn't work. ~~~ var data = []; data[0]=v1cont.add(Ti.UI.createButton({title:L('string1'), custom_item: 1, width:btnWidth,...
Webview - declare a variable that has been passed into webview
I am wanting to declare a var using data passed into the webview from TI. .html file ~~~ Ti.App.addEventListener('ad_id',function(e) { var url_item = e.id; }) ~~~ Then later down the html. ~~~ <script...
How to structure this code better so that the code doesn't run synchronously.
I'm retrieving JSON information fine referencing a method in a seperate .js source. The trouble is, while the method is running, the code on the current source is being run synchronously, and hence the return variable is still length 0. How do I structure...
Weird can't find variable afte Ti.include
Hi, I have a.js and some global variables (lat,lon). Then I write Ti.include(b.js) and in the b.js I write Ti.include(c.js). The lat and lon are accessible but I get this error: [WARN] Exception in event callback. { line = 102; message =...
passing row data to new widow
I'm trying to pass some of my row data to a new window, pretty much like a mash-up of the KS custom_properties.js and KS twitter examples. The problem I am having is that instead of passing the data from the row selected, I am passing the data from the...
Variable declared with the same name in two separated object spaces replaced the other's value..
I detected a wierd behaviour...I was using a variable declared in one js (using common Js) ObjOne.js ~~~ function ObjOne(win,id) { var x; PatientHospitalButton.addEventListener('click', function(e) { var w =...
String that get used thru out the app
Hi. I wonder if it is some way to do an alertbox where the user can input a name and then use that name as a variable in the name. Scenario: The user has a facebookpage named "Greatfbpage" When they start my app they get an alertbox propmting...
Full variable length in expressions window
I'm interested is there any way to display full variable's value in expressions window? Now it's displayed as ``` few_first_characters... (length: 1000) ``` 
Pass PHP variables to JavaScript
So, I'm trying to pass a value from php to javascript. I already tried some codes that I found in the internet, mas nothing works. I have json to pass javascript to php and then return to javascript but in this part I just want to pass a value from php to...
createView inside a function, make it global?
Hi everyone, I'm new to this forum and just started today trying to learn about Titanium SDK. I'm looking forward to learn from- and contribute to this community in the future. I have a problem that I can't find a solution for in this forum/google (maybe...
Create variable name from value?
I would like to create a variable name from a input value. For example if I had param['kitchensink'], I would like to create a variable called pp.api.data.kitchensink, so I could do something like pp.api.data.kitchensink = results. I know in other...
Using Event Listener to set value variable
Below is my code... ~~~ dialog.addEventListener('click',function(e){ if(e.index == '0'){ return carSelected = 'car1'; }else if(e.index == '1'){ return carSelected = 'car2'; } }); ~~~ I can't seem to get the variable out of the event listener....
Global variable inside an event function
I can't set a variable inside an event function? ~~~ var xhr = Titanium.Network.createHTTPClient(); var data; xhr.onload = function() { data = JSON.parse(this.responseText); }; xhr.open('GET', 'example.com'); xhr.send(); // This show...
Same variables - different values from XML
Hello I am building an RSS reader based on the example of Two App guys. I am getting my RSS feed correct on the main window where all the titles of the post are the variable this_post_title. But when you click on one of the articles you are forwarded on...
Global Socket Connection
I'm wondering what the best practice is to establish a socket connection (I am using socket.io) and have that socket globally shared throughout the app? Being that each window has it's own scope, and common.js modules don't retain state between instances,...
Storing json as a variable
I have an app that currently uses an array to store data in the form of ~~~ var tracks = [ { title : "title 1", username: "user", stream_url: "url here", artwork_url: "img url here also" }, { title :...
titanium array variable item pushed from webview checkboxes onCheck
Hey folks, Is there any way to get the Titanium array variable get assigned a value from webview scripts. Scenario is that I looped 10 times and at each time I created a row which consist (checkbox created by webview+label to show the items), and I wrote...
Preferred way to access variable inside eventlistener
What's the preferred way to access variable inside an eventlistener? I found there are many ways to achieve this and curious which method could be used to avoid memory leak ~~~ var win = Ti.UI.createWindow({ objImg: null }); var img =...
Calling some HTML files from a single .js
Hi, I´m newbie and I´m testing Titanium. I have a list with link to others .js and it´s working nice: ~~~ var data = [ {title:'Family One', hasChild:true, test:'../test/one.js'}, {title:'Family Two', hasChild:true,...
Store GPS location in a variable
Hi, I have a problem when I want to store the longitude and latitude within a variable. my code is: ~~~ var longitude_; var latitude_; Titanium.Geolocation.getCurrentPosition(function(e){ longitude_ = e.coords.longitude; latitude_ =...
Scope Error
I seem to be running into a scope problem with Titanium. To the best of my knowledge the scope of a variable is the set of brackets {} in which it is declared and any nested brackets. If the item is declared in a for loop the scope is the nested...
String to Int? Am I crazy?
I'm trying to do what I feel should be exceptionally easy, and I don't know if I am just hitting a mental roadblock or what. I've searched all over Google and tried looking through some similar Q&A questions but nothing was specifically what I'm having...
Multiple custom variables in an object?
Why would this work fine ~~~~ var bHelp = Ti.UI.createButton({ title : 'Help', _file : 'help-recipes.html' }); ~~~~ but this breaks everything that comes after it: ~~~~ var bHelp = Ti.UI.createButton({ title : 'Help', _file :...
get value of var inside function
Hello! I need your help guys!! I created a table view with text fields for a login window. But How can I get the values of the fields outside the functions? Thank you very much!! `inline code` var win = Titanium.UI.currentWindow; var tabGroup =...
Crash after set a textfield value ... the second time.
I have a strange behavior. I assign a value to a textfield, this time works good. But in another part of the code, in the same .js, i assign a new value to the same textfield, and the program crash. Example: ~~~ var dblVariable; dblVariable =...
Passing a variable from app.js to webview
I am developing a mobile app for android and iOS. I have two variables (lat and lon) that are assigned values of GPS coordinates created with Titanium.Geolocation.getCurrentPosition in my app.js page. The webview's url is map.html (local) The map.html...
Create multiple variable in a loop
Hi, i want to how can i do to create multiple variable with a loop. Like this: ~~~ for (var j = 0; j < selectedData.length; j = j + 1) { var basicSwitch = Titanium.UI.createSwitch({ right:0, style:Titanium.UI.Android.SWITCH_STYLE_CHECKBOX, ...
Add a background image o a button from a variable
Hi I am trying to make an app. Where i click a button and then it opens up the contact picker. After you select a person it should change the button image to the picture of the contact. Heres the code I am...
Namespaces may be the end to my sanity.
I seem to have an issue perhaps not specifically with name-spacing, but with order. A variable I expect to be set, isn't. In ui.js... ~~~ Ti.App.http.test(); alert(Ti.App.http.rs); ~~~ In http.js ~~~ ... http.test = function() { xhr.onload =...
Global variable in same js problems
Not sure why this code isn't working... My array is fine, my "lat" variable is declared early as var lat; . It seems like I can set it inside the forwardGeocoder function, but I need access to it after it is set, because I'm looping through a...
How to pass a variable to a .js file worker thread?
I'm coding a desktop application and I need to be able to download and save files as well as update the user as to download progress. Here is the code of the main index file: ~~~ <html> <head> var BINARY_UNITS= [1024, 'Ki', 'Mi', 'Gi', 'Ti',...
Use variable outside of JSON onload function
How i use a variable outside of JSON onload function? My code: ~~~ var posicion; var item_no; sendit = Ti.Network.createHTTPClient(); sendit.open('GET', 'http://xxxxxxx/json/json.ashx'); sendit.send(params); sendit.onload =...
Global Object
Is it possible to create an instance of an object like this: ~~~ var myObject = new FooBar(); ~~~ in app.js and be able to use this in child windows? I know I could store data via Titanium.App.Properties, but you can't store methods (functions) in that...
Passing data to a Global variable?
I am trying to create a navigation group app, with a series of windows. I need to have variables in the main application which I can set from the individual windows and then access from other windows. I tried creating a file for this purpose...
Give a variable to a view, and get it on click event (gives undefined!)
Hello I have created multiple views in my application, and I would like to give it a custom variable so i can get it on the click event. Here's my code: ~~~ while(booths.isValidRow()) { var label = Titanium.UI.createLabel({ text:...
Check if iAds exist
Hi, I'm trying to see if an object, specifically iAds, have been created yet. I tried if(iAds != null){} but that doesn't seem to work. How can I check if the createAdView function has been called yet? Thanks, and let me know if I need to clarify...
iPhone audio playback
I’ve had some success recording audio and then playing it back. What I would like to do is play it back at a different speed (say double or half speed) rather than at “normal” speed. I haven’t found a way to do this in Titanium, or by a call to...
Showing 1-50 of 65 1 2