appcelerator - Using Global Function in Titanium -


i making titanium mobile project want make 1 global function can use throughout application. have created other .js file have defined function , including .js file need use function , able call function.

but question :

can create new window in function? have added 1 label , 1 mapview in window not showing, while @ start of function have added alert('functioncalled'), showing me alert not showing me label have added in window.

so can me find out whether can open window through function. if yes sample example, can find out mistake making.

thanks,

rakesh gondaliya

you approach can work not best practice, should create global namespace, add function namespace , include file function once in app.js

// apps.js var myapp = {}; ti.include('global.js','ui.js');  myapp.ui.openmainwindow(); 

then create seperate file our ui functions

//ui.js (function(){  var ui = {};  ui.openmainwindow = function() {     // open window stuff      // call global function     myapp.global.globalfunction1(); }  myapp.ui = ui; })(); 

here create our global functions, not have include file everywhere since adding our global namespace

//global.js (function(){  var global = {};  global.globalfunction1 = function() {     // super global stuff }  myapp.global = global; })(); 

this simple outline of how can implemented, have complete code listing on my blog


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -