{ "id": "170511", "key": "AC-5418", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "10000", "description": "", "name": "Done" }, "resolutiondate": "2017-12-13T21:06:54.000+0000", "created": "2017-12-01T11:44:25.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-12-13T21:06:54.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14544", "name": "Alloy", "description": "Please enter tickets related to the Alloy here." }, { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "The following example fails if using the formFactor attribute.\r\n{code:xml|title=views/corsi.xml|borderStyle=solid}\r\n\r\n\t\r\n\t\r\n\t\t\r\n \t\r\n \t\r\n \t\r\n \r\n \r\n \r\n \r\n \r\n \r\n \t\t\r\n\t\r\n\t\r\n\t\t\t\r\n \r\n \r\n \r\n \r\n \t\r\n\t\r\n\r\n{code}\r\n\r\n{code:title= controllers/corsi.js|borderStyle=solid}\r\nvar args = arguments[0] || {};\r\nvar collection = Alloy.Collections.Corsi;\r\n\r\ncollection.fetch({\r\n\terror : function(){\r\n\t\tAlloy.Globals.loading.hide();\r\n\t},\r\n\tfinish : function(collection, response) {\r\n\t\tAlloy.Globals.loading.hide();\r\n\t},\r\n\tlocalData: true,\r\n\tinitFetchWithLocalData: true\r\n});\r\n\r\n\r\nfunction toggle(e) {\r\n var fn = 'toggleLeftWindow';\r\n Alloy.Globals.drawer[fn]();\r\n}\r\n{code}\r\n{code:title=models/Corsi.js|borderStyle=solid}\r\nvar Mutators = require('vendor/backbone.mutators');\r\nvar utils = require('ui/utils');\r\n\r\nexports.definition = {\r\n config : { \r\n URL: \"http://xxxx.com,\r\n \tdebug: 0, //debug mode enabled\r\n \tuseStrictValidation: 0, // validates each item if all columns are present\r\n adapter : {\r\n type : \"sqlrest\",\r\n collection_name : \"corsi\",\r\n db_file : \"/xeniasoft.sqlite\",\r\n db_name : \"xeniasoft\",\r\n //idAttribute: \"rowid\",\r\n remoteBackup : false \r\n }, \r\n \t \tinitFetchWithLocalData : false,\r\n \tdisableSaveDataLocallyOnServerError : true,\r\n \tlocalOnly: false,\r\n \tdeleteAllOnFetch: true,\r\n \tparentNode: function (data) {\r\n \t\treturn JSON.parse(data);\r\n\t\t}\r\n },\r\n\r\n extendModel: function(Model) {\t\t\r\n _.extend(Model.prototype, {\r\n // Extend, override or implement Backbone.Model \r\n mutators : { \r\n titolo : {\r\n get : function() {\r\n return \" \" + this.get(\"corso\") + \" \";\r\n }, // get\r\n transient : true\r\n },\r\n trainer : {\r\n get : function() {\r\n return L('istruttore') + this.get(\"istruttore\").toUpperCase() + \" \";\r\n }, // get\r\n transient : true\r\n },\r\n image : {\r\n get : function() {\r\n return (this.get(\"foto\") != \"\") ? this.get(\"foto\") : \"/images/placeholder_big.jpg\";\r\n }, // get\r\n transient : true\r\n },\r\n imageList : {\r\n get : function() {\r\n return (this.get(\"foto\") != \"\") ? this.get(\"foto\") : \"/images/placeholder.jpg\";\r\n }, // get\r\n transient : true\r\n },\r\n\t\t\t\tlezioni : {\r\n\t\t\t\t\tget : function() {\r\n\t\t\t\t\t\tvar sql = \"SELECT * FROM lezioni WHERE id_corso=\" + this.get(\"id_corso\");\r\n\t\t\t\t\t\tdb = Ti.Database.open('xeniasoft');\r\n\t\t\t\t\t\tvar rs = db.execute(sql);\r\n\t\t\t\t\t\tvar output = [];\r\n\t\t\t\t\t\twhile (rs.isValidRow()) {\r\n\t\t\t\t\t\t\tvar g = utils.getGornoSettimana(rs.fieldByName('id_giorno')) + \" \" + rs.fieldByName(\"ora_inizio\") + \" - \" + rs.fieldByName(\"ora_fine\");\r\n\t\t\t\t\t\t\toutput.push(g);\r\n\t\t\t\t\t\t\trs.next();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\trs.close();\r\n\t\t\t\t\t\tdb.close();\r\n\t\t\t\t\t\treturn output;\r\n\t\t\t\t\t},\r\n\t\t\t\t\ttransient : true\r\n\t\t\t\t}\r\n }\r\n });\r\n\t\t\r\n return Model;\r\n },\r\n\r\n extendCollection: function(Collection) {\t\t\r\n _.extend(Collection.prototype, {\r\n // Extend, override or implement Backbone.Collection \r\n\t\t\tgetCorso : function(id) {\r\n\t\t\t\tvar collection = this;\r\n\t\t\t\t\r\n\t\t\t\tvar sql = \"SELECT * FROM \" + collection.config.adapter.collection_name + \" WHERE id_corso=\" + id;\r\n\t\t\t\tdb = Ti.Database.open(collection.config.adapter.db_name);\r\n\t\t\t\tvar rs = db.execute(sql);\r\n\t\t\t\tvar output = [];\r\n\t\t\t\tif(rs.isValidRow()) {\r\n\t\t\t\t\toutput.push({\r\n\t\t\t\t\t\timageList: (rs.fieldByName(\"foto\") != \"\") ? rs.fieldByName(\"foto\") : \"/images/placeholder.jpg\" ,\r\n\t\t\t\t\t\tcorso : rs.fieldByName(\"corso\"),\r\n\t\t\t\t\t\tdescrizione : rs.fieldByName(\"descrizione\"),\r\n\t\t\t\t\t\tistruttore: rs.fieldByName(\"istruttore\"),\r\n\t\t\t\t\t\tsala : rs.fieldByName(\"sala\"),\r\n\t\t\t\t\t\tprenotabile : rs.fieldByName(\"prenotabile\")\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\trs.close();\r\n\t\t\t\tdb.close();\r\n\t\t\t\t\r\n\t\t\t\treturn output;\r\n\t\t\t}\r\n });\r\n\t\t\r\n return Collection;\r\n }\r\n};\r\n{code}\r\nThis will generate the following code.\r\n{code}\r\n...\r\n{for(var d,f=a.opts||{},g=j.models,h=g.length,k=[],l=0;l