Community Questions & Answers
Alloy Common Code
Hi, i am using Alloy to build an iPhone mobile App, and there's a part of the code that must be the same in the all sections... can i use something like include in PHP ?? thanks
Best way to create a reusable custom control???
Im not quite sure the best way to do this so any help is appreciated. Essentially I want to make a reusable timepicker control that I can just call on any page and not have to reinvent the wheel every time. Im not sure if the best way is to create a...
Alloy, help with strange library inclusion behavior on ios?
I am creating an alarm app in alloy (mostly for practice). And there are several functions that I am going to need in several controllers. So, i made a library. ~~~ module.exports = (function(){ return { /** * Creates a checkbox which can be used on...
Require global function in alloy.js, error at startup on device.
I want to use the same instance of "Data" from all my controllers and makes is global in alloy.js. It works fine in the simulator but on my device I get "Application Error: Couldn't find module: Data" at startup. I'm using Titanium SDK...
More Samples for apps
I am reviewing samples from Trevor Ward's custom menu and Kitchen Sink. I would like to request more samples that follow the Listview in order to create tabbed and navigation based apps. Ill be using a Win 7 x64 computer. Thanks.
url:
Using the latest 3.1 Titanium studio with latest SDK. I am just trying to build a simple tabbed app. Going through the documentation reveals attaching windows via a url:"todo.js" Using commonjs and the latest build. This wont happen and gives me...
Titanium & CommonJS: How to switch from one view to another?
I am new to CommonJS programming pattern. I know that I can create several modules for each view, but I have no idea how to interact between them: Example: I create a view, including some labels and text in view1.js. There is a button "next...
Object oriented programming CommonJS and Prototype (Async preserve of 'This')
Hi guys I have a rather technique question than a troubleshooting. I am trying to have a clean OOP structured code but always run into problems doing so, I am using CommonJS and am open to different suggestions on doing doing so. My current dilemma is...
CommonJS and Event Listener calling prototype function
I am trying to have Event Listener call a prototype function (method?) inside a CommonJS object as follows: ~~~ MainMenuEntry.prototype.initializeEventListener = function() { this.mainMenuEntryView.addEventListener("click",...
Alloy UI variable space and module space private?
Perhaps the question title is a little misleading. My understanding of Alloy controllers in Titanium is that they have their own context, unless you throw them in a global space or pass parameters from one controller to the next upon creation. I have two...
CommonJS Error: '' is not a constructor
The following code works only in Android but not on iPhone: Platform.js ~~~ function Platform() { } module.exports = Platform; ~~~ app.js ~~~ var Platform = require("platform"); var platform = new Platform(); ~~~ What am I doing wrong here?...
Scope in commonJS module
This code: ~~~ function Model() { return this.init(); } Model.prototype.init = function() { var self = this; self.getVehiclepos(); this.cron = setInterval(self.getVehiclepos, 5000); return this; }; Model.prototype.getVehiclepos = function()...
require commonjs with alloy
Hi, I created a folder in the same level with controllers, models, views folder. this folder is named lib and contains : analytics.js in index.js i writed require('/lib/analytics') but i have requested module not found.. where is the problem ? thanks
Use "else if" inside of function to use as a module.exports
I used this a version of this in a ti.include, without an problems. I am trying to figure out how use it in the ti.require module. `[ERROR] : Script Error = 'undefined' is not a function (evaluating...
Creating static properties/functions within an Alloy Controller
Hi, I need to create a static property inside a controller. Since Alloy generates a CommonJS module, the way to create a static property or function is declare them outside the exported function [According to...
Window Hierarchy issue? CommonJS to Alloy Conversion Problem
Ok, so I am trying to convert a non-Alloy twitter oAuth project I found online to an Alloy Tumblr project. I'm really close in that I got the Tumblr part working on the non-Alloy project, now I am just trying to convert it to Alloy. As you will see in the...
How do I implement/convert a CommonJS/exports project to work with Alloy?
I have a project I am working with that currently has this type of setup: **app.js** ~~~ (function() { var Tumblr = require('tumblr').Tumblr; // rest of code here })(this); ~~~ **tumblr.js** ~~~ var exports = exports || this; exports.Tumblr =...
module.exports in Android Alloy not working - Uncaught TypeError
I have an app which all works fine in ios but not android and I'm struggling to understand why. In Android I get a Message: Uncaught TypeError: Object function Controller() { error and another error of has no method 'allEvents' If I remove the...
theoric question about views loading other views
If from view A, I import (require) a commonJS module containing a view B, once B is loaded upon A (B is a rectangle of the same dimensions of A), can I safely remove A (A=FirstView) from memory?
Problems managing CommonJS modules
Hi all, I am using Titanium Mobile SDK 3.0 to develop apps for iOS. I'm running OSX Mountain Lion. I am using the CommonJS approach. I'm having problems though. For the life of me, I cannot still figure out how to structure my code. Example: ~~~ /*...
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
Reload music player module
Hi, I have a table view on a page. Each row is ment to load a different url into a player. If I click on a first row, the player is working fine. However, as soon as I click on another row to load another url, the player is going crazy. Actually it is...
CommonJS Modules as Windows and Memory
Hi, I am doing my best follow Ti Studio's best practices and I have the following situation/question. I have a module inside which there is a table view where each row is the id to an ACS place. When a row is clicked I call the following...
Titanium alloy & CommonJS files
I am using Titanium Alloy. Where should I be placing the CommonJS files in my project? The documentation indicates that the files should be placed relative to Resources folder, however this is dynamically generated in Alloy. When I place the file in say...
Change activeTab on button click in CommonJS
A complete and mostly working app was dropped in my lap. I'm changing it to use the recommended commonJS modules. The Home tab of the app is basically 6 buttons. When a button is clicked, they switch to the corresponding tab for that button(search button...
Alloy controllers scope vs commonJS modules
This is both a question and a thought about how to manage some situations in Alloy. Formerly, working with commonJS modules was very useful to have some module-scope variables that could be shared by multiple instances of a module. For example, for a...
Best way to pass tablerow data in commonjs?
The old way to do it doesn't work. I can pass the data through properties, but not by adding it to the event listener. The title will pass, but not the row id. ~~~ tableview.addEventListener('click', function(e) { if (e.rowData.path) { var win =...
require() not working with CommonJS module
I have a module defined as such: analytics.js ~~~ function Track () { ... } ... module.exports = Track; ~~~ I am requiring the module like so: app.js ~~~ //CommonJS modules var Track = require('analytics'); zc.track = new Track(); ~~~ When I...
Script Error = Can't find variable: exports at mySecondScript.js
Hello, I'm getting this red screen error when trying to make an export. " Script Error = Can't find variable: exports at mySecondScript.js " Weirdly, the alert with the string "my alert" shows up too! Here's...
Alloy: require commonJS
I started a new project with alloy, (the Resources folder is hidden from the App and Project Explorer.) now i added a js file to project with path: app/models/person.js. In person.js i have: ~~~ var models = (function() { alert('hi...
How to open a window from a button?(commonjs)
I am learning commonjs, and I am running into a few bumps in the road. How can you open a window from a button in a tab group? ~~~ function tv_basic() { var HomeWin = Ti.UI.createWindow({ backgroundImage:...
http callback
I use Titanium Studio 3.01, Sdk 3.0.0.0GA, Xcode 4.6 on a Mac. I am still converting my apps to commonjs and am experimenting with call backs, can someone see what is going wrong in this code. Ti.Api.info shows the response is getting to unload but I get...
Alloy or CommonJS with Netbeans
Hi friends I am an old Titanium developer been using it since 1.2 SDK.For last one year I have not done any development and found about certain changes like introduction of **CommonJS** and now **Alloy** Now how do I use non Titanium Studio environment...
how to show value of table in data base in in window?
I made data base and i can save but now i wont to see the value of table of data base but in new window..........
Alloy with CommonJS module gives 'undefined' is not a constructor
Before updating to 3.0 I had a CommonJS Module I made that worked just fine. Not that I've upgraded I seem to be having trouble creating a instance of the object. The CommonJS Module is below ~~~ exports.apiVersion = 1.0; function...
changing to common's
Hi, I use Titanium Studio 3.01, Sdk 3.0.0.0GA, Xcode 4.6 on a Mac and have spent the morning reading through the forum and guides about commonJS. I am trying to change over to this method of coding and now have my initial setup using the default tabbed...
Problem of common js in titanium how to solve it
Hi I have come across a very strange problem.My code is working fine.Its just when i try to access the HomeScreen from the LastScreen.The app simply does not work and stops after sometimes.Here is how i try that ~~~ var...
commonjs build failed iOS simulator
~~~ [INFO] : Copying CommonJS modules [ERROR] : ** BUILD FAILED ** [ERROR] : The following build commands failed: [ERROR] : CompileC build/projectname.build/Debug-iphonesimulator/projectname.build/Objects-normal/i386/ASIInputStream.o...
Form validation using CommonJS
Hi I'm a noob building an Android app on Titanium 3.0.1 with Windows 7 and I'm building it using commonjs. On my login screen I want to validate a form and I want to put the validation function into a seperate file, like so: ~~~ //...
comman js using
i wont to know how to use comman js and why i am use it but with code,please
Error in callback from acs with Alloy
I’m working in an app that has a log in and a home screen.I'm using acs to log in. . On Android, problem is on the response from acs for authentication, no matter it’s an error or a success, callback isn't working. On iOS, ACS callback is working OK....
Does passing an object between modules keep equals to global vars?
I'm a beginner with appcelerator. I was reading a little bit on best practices and saw that like js, using global var is bad. In my code, i have a xhr call to server and onload, I open a new window. to this window, I like to pass some settings, including...
Does Titanium wrap modules (files) in an IIFE or is it global?
I was looking through some code and noticed that many of the CommonJS modules started declaring local variables in the file without being wrapped in a function to scope everything from the global space. Most systems (like CoffeeScript) automatically wrap a...
Object not available in IOS and I don't know why...
I am having an issue where an object's properties (a scrollableview in this case) is not available in a JS file in IOS, but works fine in Android. Here is the scenario. I have a js file where I declare the scrollableview (sv) variable at the top of the...
Best way to call to functions from exports
Ok i am working on a basic loader which i have in a file called loader.js here is my loader.js ~~~ exports.loader = function() { self = Ti.UI.createWindow({ width : Ti.Platform.displayCaps.platformWidth, height :...
CommonJS module not working in iOS simulator
Hi, I am trying to use a CommonJS module in my app, which works perfectly fine for the Android Emulator but fails in the iOS simulator. This is the code i used for testing: app/lib/database.js ~~~ exports.info = function(str) { Titanium.API.info(new...
Several views one win best practise
Hi. I want to clean up my coding and make things the right way. What i have trouble understanding is how to get 3 different views in to same win and changing between them. Lets say that i have a win with a toolbar and three buttons on it. Each button...
Convert JS library to CommonJS module
Hi, is it possible to convert this library to a CommonJS module? https://github.com/ddehghan/Titanium-PredictiveCache/blob/master/README.md Any tips?
the memory management of commonJS
i have a question about the memory management of commonJS module. considering the following two code slice, my question is when the `win` close, all objects defined in the module will be released? The following two situations are the same? ~~~ function...
Logindialog crashes
Hi, for realizing of login dialog I build a window: ~~~ exports.create = function(model, _callback) { var self = Ti.UI.createWindow({width : 272,height : 200,}); self.open(); self.cancel =...