Community Questions & Answers
Triggering fireEvent from WebView's html.
Hey guys! **[This is on the iPhone]** I've been trying to trigger this function: ~~~ Ti.App.fireEvent('openLink', {url:"'+_myUrl+'"}); ~~~ From inside my html. Here's how it looks: ~~~ <javascript Titanium code> ... //Inline HTML...
Access Functions/Variable within a Controller from another Controller
This same question was essentially asked [here][someid], but I do not believe it was fully answered. I have a MasterView (alloy xml & controller) that holds multiple instances of a SubView (separate alloy xml & controller). However, there are...
How to use buttons from outside a function PLEASE HELP!
Hi all , I want to know if it is possible to create a function that creates a window and all of its buttons and features and then call one of the buttons from outside the function for example ~~~ function HomePage(e){ var winHome =...
Function Using Problem
Hi folks ,I m using Ti 3.0 and for ios6. My code is below. and I want to use my function multiple times.I want to reuse my function. when I add win1 no problem.but When I add win1 and win2 .this app crashed. ~~~ //tasarim.js function...
Use function in different .js
Hey there, I'm using the latest Titanium Studio(3.0.1) and developing with a default android SDK of 2.2. I was wondering if i could create a function in my app.js which can be used in different JS files aswell. Is this possible, and if so: How? For...
Property of object is not a function
I am pretty stumped on this, it seems like it should be dead simple. I have a function called toast() that I use all the time in my code without problem (Note, this is my own function, I am not trying to call for an android toast!) But when I call it from...
Following the Kitchensink format, I get function error.
Hi, I followed the structure of the Kitchensink to create a new app. HEre is what I have done so far: 1. Created a New Project. 2. The app.js looks like this: http://pastie.org/6123422 3. Than I created the ApplicationWindow.js file inside the...
Global AudioPlayer function
Hi, I'm trying to create a global AudioPlayer function for my iOS/Androïd app and wanted to find an example to understand how it works. My goal is to make my app able to use the same AudioPlayer on three different tabs, when a new player is launched,...
global Activity Indicator?
instead of creating activity indicator in every window Is there a way to use activity indicator as an global function and call it whenever needed ? Iam in need to use an activity indicator which in turn placed inside a view,which has to be called on each...
Namespaces explanation!
I am having this code which I found open source: ~~~ var abc = {}; // namespace abc.dosth = function(msg, enc) { //HERE I CALL ALL OTHER FUNCTIONS SO I JUST HAVE TO FIND A WAY TO CALL THIS FUNCTION FOR STARTERS return sth; } abc.dosth2 =...
How can i create Synchronous Processes?
Hi all, I'm interesting to create a process (a function for example) and wait until it's finish in order to execute the second process (function). I want to achieve truly synchronous process especially for two consecutive events: ~~~ //In theory these...
Pull items from Database
Hey Guys, I'm stuck at a tricky part of the development of my app and I was hoping you guys could help me out. I managed to pull all of my content on the view from a sqlite database file, but I can't get some items to work. If you look at my code below,...
Not getting a value back from a Cloud callback function
Hi guys, Ok, I'm scratching my head trying to figure out what I'm doing wrong here. I'm trying to get a value back from a function but nothing I do seems to get the value back! Before anyone suggests it... YES I have tried this in the more 'normal' /...
Accessing a function from other .js file
Hi I want to access a function from other .js file.Actually there are two .js files.In one js file i have write the function as.This is db.js ~~~ function quizfun() { var quizes = db.execute('select * from Quiz'); while (quiz.isValidRow()) { var...
Array not returned properly
I am returning the array using a function in titanium.There are two entries in my array which are showing alert but when i access the returned value in another js file.It only show one value in alert Here is my code (it is in db.js): ~~~ function quizfun()...
Global functions - workds from app.js, fails from everywhere else
I have a file called "core.js" which resides in /Resources/includes directory. And the file holds one simple function: ~~~ (function(){ GetPath = function () { var Path; // If something bla bla bla return Path; } })(); ~~~ And then...
How can i define a method in my module?
Hi, I have two js-files. file1.js ~~~ function test1() { // create a tableview or something } function method1() { // access to variables which are defined in the constructor test1() // should it be an inner function? } module.exports =...
function output
Hi there, i am curious about some issue, is there a way to put a function output to a variable? For example: ~~~ var get_url = function(video_id){ var xhr = Titanium.Network.createHTTPClient(); xhr.onload = function() { var...
call function within function commonjs
If I have a function inside of an "exports" function, can I call that function from another commonJS module? ex below ~~~ //this is table.js exports.TableWindow = function(){ //create base window var self =...
pass value to function
Does anyone know how can I pass the custom message to sayhi function ? //win.js var btn = new ui.button(standandBtn('Button'), sayhi) function standandBtn(title){ var obj = {top:10, left:10, title:title}; return obj; } function...
App launch error - undefined is not a function
I've been looking in to using commonJS and have run in to a problem right at the start of the app launch. I get the error `[ERROR] Script Error = 'undefined' is not a function (evaluating 'app.launchApp()') at app.js (line 3).` - I think I'm completely...
Result of expression 'Titanium.Geolocation.watchPosition' [undefined] is not a function
Hi folks, I know I am doing something fundamentally wrong here as when I try to run my code I get the following error...... "Result of expression 'Titanium.Geolocation.watchPosition' [undefined] is not a function" I am a newbie to app...
Problem with IOS module function in SDK 2.1.0
Hi, I have a custom module that return a list of strings. In 2.0.2 it works fine, and I call the function like that : ~~~ var list = connexion.getNamesFromServer(); ~~~ now with 2.1.0 it raises an error like this : ~~~ message = "'Name1,Name2' is not...
CommonJS difference Between iPhone and Android
Is there a reason why the following code works on Android but not on iOS. Here are the 4 js files that are needed to demonstrate the issue. app.js ~~~ (function() { var Window = require('ApplicationWindow'); new...
diff two arrays of objects
I'm googeling and working for days on that problem, and I don't have any solution yet. I want to diff two arrays of 1-level objects. I want to compare each field of every object. On difference push it to a result array. Maybe the community has an answer...
Asychnronous issues
Hi guys, I am trying to create modules(mapview,network,geolocations etc) and I face the asynchronous issue. For example I have the geolocation.js: ~~~ exports.getLocation = function(){ var lat=""; var lon=""; // Ask the user for...
Tableview not clearing on refresh using custom event
Hi guys, I've found a bug in my app which I need to fix in the next update. A user can select their favourite team (myclub.js), and then remove it later if they wish in the settings screen (settings.js). By removing their team in settings.js I trigger a...
Keycode.
Greetings, the Keycode works in Titanium ? for example a function to detect if a variable is number: ~~~ function isNumber(numero){ var charCode; charCode = numero.keyCode; if (charCode > 31 && (charCode 57)) { return...
After animation return to opacity 1 not working
Thanks in advance! I´m doing a simple image slide show and when I do an animation with an image, when it finished I need to return to 100% opacity, but not work: ~~~ myimage.animate({opacity:0,duration:4000},function (){ myimage.opacity=1; }); ~~~ I...
Arrays / scope (a Yelp example)
I'm having trouble passing back data returned from using Yelp 1.0 API. The function accepts a latitude and longitude (static from a database, not from dynamic geolocation). I want to return variable data from the results (yelp results lat, lng, name, url,...
Add to an Array
I'm drawing a blank, how do I use a function to add to an array? ~~~ var cartItems=[]; function addItem(title, car, color, qty, price){ var item = [{title: title, car: car, color: color, qty: qty, price: price}]; cartItems.push(item); } addItem(Hub...
Android - Simple listener function problem
Hi guys, I'm having a bit of a problem. I've got 9 image views (img1, img2, img3, etc) and I want to add a click event listener to all of them. I've tried saving the function as a variable but somehow the `e` isn't associated with the imageview. example...
passing data or function between files appcelerator
hi all i've problems. this is my code: i've 2 file name index.js, and city.js ~~~ var win = Ti.UI.currentWindow; function initMain(x) { alert(x); var data = []; var row = Ti.UI.createTableViewRow(); for(var c = 1; c < 5; c++) { var row =...
Exit from a function
~~~ // how to exit from funtion after errorDialog.show() ? function myfunction(e) { if (text1.value == '' || text1.value == null) { var errorDialog = Ti.UI.createAlertDialog({ title: 'Error!', message: 'You must provide a value...
Why can't I call a function from an event listener?
I have an event listener, which I'd like to call a function: ~~~ function goSubView(which){ var page = 'html/' + roofType + '_' + which + '.html'; wv2.url = page; bb1.index = which; }; bb1.addEventListener('click', function(e) { var i =...
declaring a function -effects on performance
Is there an difference between something like var x=function(){} and function x(){} What effect does a function declaration have on performance?
Result of expression 'Titanium.UI.createButton' [] is not a function
When loading a window, I'm getting the following error: [ERROR] Script Error = Result of expression 'Titanium.UI.createButton' [] is not a function. at userHome.js (line 142). Nothing changed in the code. I recently upgraded the SDK version. I've already...
Picker Strange problem
I am updating an older app I made and having a weird issue with the picker. I'm using the 1.3 SDK and the picker displays fine until I add this function. If I comment out the "var = HT" line, the picker comes up fine. My whole app is based on...
Creating a library of methods
Ok, so I know this is more of a JavaScript question, but it's possible that Titanium Studio might have some of their own ideas (or requirements) on the best way to do this, so I hope it's okay if I ask it here. In this little learning app I'm doing, I...
Question about calling an instance/object
titanium sdk 1.8.2 iphone sdk 4.3 Hi, If I call the function this way, via a click of a button: ~~~ addBtn.addEventListener('click', function(){ var addview = new AddView(); self.add(addview); }); ~~~ if I click the button again and again, does it...
Detect if exist an image URL
Greetings, How I can know if there exist an image URL?, I need to load an image from a URL but if there is no load another, how i can? ~~~ var image = Ti.UI.createImageView({ url : 'http://xxxx/image.jpg' }); if (image.url.exist()) { // Do...
how to hide a function/module?
titanium sdk 1.8.2 iphone sdk 4.3 Hi, I created two windows using two different functions/modules and its ocurence is controlled by a play and pause button. When I pressed the button, the function gets loaded overlapping the play view, which is ok. ...
Open and close mail function in the same win/tab
Hi! I have created a sample project in Titanium with two tabs. Inside of win 1 in tab 1 I've also created a button. On click, a new win opens inside of tab 1 with the mail function. Which giving an extra window when I close or send an email. ~~~ var...
Event Listener Not Detecting Click in Function?
Why is the event handlers not picking up the click within this function? ~~~ function androidPickerColumn(left,top) { var pickerColumn = Titanium.UI.createView({ text: '0', width: 57, height:...
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...
how to turn local variable to a globale variable
here is my code: function makeSearchRow(){ Ti.App.addEventListener('recevingCall', function(event){ mySearchWin.name = event.name; }); ...... ...... }; my question is , how do I turn "mySearchWin.name" this variable into a global...
Refresh Window
Hi, I have no problems refreshing the window by pointing the button to the ~~~ function ApplicationWindow() {} ~~~ However, the screen is not updated with the proper information. It remains the same. The ApplicationWindow ~~~ //Application Window...
Remove a TableView from a function
I created a function: ~~~ var newsTopic = function() { var tableview = Ti.UI.createTableView({ data:data, top:68, backgroundColor: '#fff' }); news.add(tableview); } ~~~ and ran the function ~~~ newsTopic(); ~~~ I have a...
How to pass argument to custom function within setInterval()
I have this custom function defined within setInterval() which begins as soon as the application starts and executes every 2 seconds. `setInterval(function() { xhr.open(post,url); xhr.send({userID:1}); },2000)` I want to define an argument instead of...