function onClickSave() { if ($.titleTxt.value) { if (!$model) { $model = Alloy.createModel("item"); items.add($model); } $model.set("title", $.titleTxt.value); $model.set("notes", $.notesTxt.value); $model.set("dueDate", $.dateTxt.value); $model.save(); Ti.Analytics.featureEvent("item.add.success", { title: $.titleTxt.value ? true : false, notes: $.notesTxt.value ? true : false, dueDate: $.dateTxt.value ? true : false }); $.addItemWindow.close(); } else alert("Oops! Did you forget to add a title?"); }
function SearchLog(reset) { var SearchControl = Alloy.Collections.Searched; SearchControl.fetch(); reset && SearchControl.reset(); debugger; var Search = Alloy.createModel("Searched", { Query: Alloy.Globals.Artist }); SearchControl.add(Search); Search.save(); Ti.API.log(" START DATA ---------------------------------------"); for (var x in SearchControl.models) { var show = SearchControl.models[x].get("Query"); Ti.API.log(show + " is :" + x); } Ti.API.log("END DATA ------------------------------------------"); var ASAP = SearchControl.models[SearchControl.length - 1].get("Query"); debugger; }
followUser: function(_userid, _callback) { var friendItem = { user_ids: _userid, approval_required: "false" }; var friendItemModel = Alloy.createModel("Friend"); friendItemModel.save(friendItem, { success: function() { _callback({ success: true }); }, error: function() { _callback({ success: false }); } }); },
unFollowUser: function(_userid, _callback) { var friendItemModel = Alloy.createModel("Friend"); friendItemModel.id = _userid; friendItemModel.destroy({ data: { user_ids: [ _userid ] }, success: function() { _callback({ success: true }); }, error: function() { _callback({ success: false }); } }); }
function saveTask() { limitTime = limitTime || Date.now(); var todo = Alloy.createModel("Todo", { task: $.inputTask.value, limitTime: "" + limitTime, done: 0 }); if (todo.isValid()) { todo.save(); $.addWin.close({ animated: true }); alert("Save"); Alloy.Collections.Todo.fetch(); } else { todo.destroy(); alert("failed"); } }
function doAuthorization(_params) { console.log(_params); _params = _params || {}; var user = Alloy.createModel("Users"); user.login({ login: _params.username, password: _params.password, success: function() { $.trigger("logined", {}); $.navigation.close(); }, error: function() { Alert.dialog({ title: "エラー", message: "ログインに失敗しました" }); } }); }
var signFacebook = function(data) { var signup = Alloy.createModel("facebooklogin", { firstName: data.first_name, lastName: data.last_name, email: data.email, facebookId: data.id, appInstallId: Alloy.Globals.core.installId, appVersion: Ti.App.version, platformModel: Ti.Platform.model, platformVersion: Ti.Platform.version, platformOSName: Ti.Platform.osname, language: Ti.Locale.currentLanguage, currency: currency }); signup.localValidate(errorHandler) && signup.save({}, { success: function(model, response) { Alloy.Globals.core.apiToken(response.UUID); profile = Alloy.createModel("profile"); profile.fetch({ success: function() { $.resetPasswordWrap.visible = false; $.resetPasswordWrap.height = 0; $.sendAdmin.visible = false; $.sendAdmin.height = 0; indicator.closeIndicator(); Alloy.Globals.profile = profile.toJSON(); Alloy.Globals.profile.supplier && Ti.App.fireEvent("account:itIsSupplier"); Alloy.Globals.profile.currency || null !== Alloy.Globals.profile.currency ? Ti.App.fireEvent("account:updateProfile") : chooseCurrency(); }, error: function() { indicator.closeIndicator(); } }); Alloy.Collections.adverts = Alloy.createCollection("advert"); Ti.App.fireEvent("account:showAccount"); }, error: function(model, xhr) { indicator.closeIndicator(); xhr && !xhr.blocked ? errorHandler(errors.CAN_NOT_CREATE_ACCOUNT) : $.sendAdmin.visible = true; $.sendAdmin.height = Ti.UI.SIZE; } }); };
function logout() { if (Alloy.Globals.profile) { var out = Alloy.createModel("signout", { appInstallId: Alloy.Globals.core.installId, userId: Alloy.Globals.profile.id }); out.save({ success: function() { Ti.API.info("destroyed"); } }); Alloy.CFG.tabAccount.title = L("tab_signin"); } Ti.Facebook.logout(); Alloy.Globals.profile = null; Alloy.Globals.core.apiToken(false); Alloy.Globals.chat.source && Alloy.Globals.chat.source.close(); Ti.App.fireEvent("account:showSignIn"); }
login: function() { var user_rest = Alloy.createModel("user_rest", { _id: "hans" }); user_rest.fetch({ success: function() { this.set({ loggedIn: 1, loggedInSince: moment().format("YYYY-MM-DD HH:mm:ss.SSS"), authKey: AUTHKEY, teamname: res.teamname }); return true; }, error: function() { alert("error"); return false; } }); },
$.contactInfo.addEventListener("close", function() { var firstName = $.txtFirstName.getValue(); var lastName = $.txtLastName.getValue(); var phone = $.txtPhone.getValue(); var eMail = $.txtEmail.getValue(); var oldValue = Alloy.Collections.contactInformation.get("1"); oldValue && oldValue.destroy(); var infoItem = Alloy.createModel("contactInformation", { id: "1", FirstName: firstName, LastName: lastName, Phone: phone, Email: eMail }); Alloy.Collections.contactInformation.add(infoItem); infoItem.save(); $.destroy(); $.off(); Ti.API.info("didnt fail silently"); });
$.btnSave.addEventListener("click", function() { var todo = Alloy.createModel("Todo", { task: $.inputTask.value, lastModifiedAt: new Date().getTime(), createdAt: new Date().getTime(), done: false.toString() }); if (todo.isValid()) { todo.save(); $.addWin.close({ animated: true }); Alloy.Collections.Todo.fetch(); alert($.inputTask.value + ": saved."); } else { var reason = todo.validate(todo.toJSON()); todo.destroy(); alert(reason); } });
function loadCustNeedRelationsIntoDB(_response, _empty, _url) { var cnr = JSON.parse(_response.responseText).d.results; cnr.length; var cnrCount = customerNeedRelationships.length + 1; for (var c = 0; cnr.length > c; c++) { var mobileContentId = Number(getMobileContentIdFromUrl(_url)); var customerId = 0; for (var mc = 0; mobileContents.length > mc; mc++) mobileContents.at(mc).get("id") == mobileContentId && (customerId = mobileContents.at(mc).get("customerId")); var modelCNR = Alloy.createModel("customerNeedRelationship", { id: cnrCount, mobileContent_id: mobileContentId, customer_id: customerId, businessNeed_id: cnr[c].Id }); customerNeedRelationships.add(modelCNR); modelCNR.save(); cnrCount += 1; } customerNeedRelationships.fetch(); }
onload: function() { readyToScroll = false; json = JSON.parse(this.responseText); eventosChild = []; eventosChild = Alloy.createCollection("eventos"); readable = true; for (i = 0; i < json.length; i++) eventosChild.push(Alloy.createModel("eventos", { id: json[i].id, name: json[i].name, image: json[i].image, date: json[i].date })); json.length < limitAPI && (readable = false); rows = []; $._L_eventos.setText(currentCategory.toUpperCase()); rows[0] = $._Tbl_eventos.getData()[0].rows[0]; for (var i = 0; i < eventosChild.length; i++) { var model = eventosChild.at(i); id = model.get("id"); name = "" + model.get("name"); image = "" + model.get("image"); date = "" + model.get("date"); var newRow = Alloy.createController("eventosChild", { id: id, name: name, image: image, date: date, detailEvent: true }); rows.push(newRow.getView()); } $._Tbl_eventos.data = []; $._Tbl_eventos.setData(rows); $._V_eventos.show(); $._V_categorias.hide(); $._L_back.setText(" Principal "); $._L_actual.setText("Eventos"); $._L_alterno.show(); eventCurrent = true; readyToScroll = true; },
function Controller() { require("alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments)); this.__controllerPath = "index"; arguments[0] ? arguments[0]["__parentSymbol"] : null; arguments[0] ? arguments[0]["$model"] : null; arguments[0] ? arguments[0]["__itemTemplate"] : null; var $ = this; var exports = {}; $.__views.index = Ti.UI.createWindow({ backgroundColor: "white", id: "index" }); $.__views.index && $.addTopLevelView($.__views.index); $.__views.label = Ti.UI.createLabel({ width: Ti.UI.SIZE, height: Ti.UI.SIZE, color: "#000", text: "Mi modelo:", id: "label" }); $.__views.index.add($.__views.label); $.__views.label2 = Ti.UI.createLabel({ width: Ti.UI.SIZE, height: Ti.UI.SIZE, color: "#000", id: "label2", bottom: "200" }); $.__views.index.add($.__views.label2); exports.destroy = function() {}; _.extend($, $.__views); var info = Alloy.createModel("info", { nombre: "Nathaniel Fisher", direccion: "Daton St" }); var nombre = info.get("nombre"); var direccion = info.get("direccion"); $.label2.text = nombre + " by " + direccion; $.index.open(); _.extend($, exports); }
function updateSchools() { var sql = "SELECT * FROM schools"; Alloy.Globals.school.config.columns; Alloy.Globals.school.deleteAll(); var tmpRS = schoolDB.execute(sql); if (tmpRS.getRowCount() > 0) { while (tmpRS.isValidRow()) { var newSchool = Alloy.createModel("school", { earlyreleasehours: tmpRS.fieldByName("earlyreleasehours"), delayedhours: tmpRS.fieldByName("delayedhours"), regularhours: tmpRS.fieldByName("regularhours"), name: tmpRS.fieldByName("name"), shortname: tmpRS.fieldByName("shortname"), type: tmpRS.fieldByName("type"), principal: tmpRS.fieldByName("principal"), principal_emailaddr: tmpRS.fieldByName("principal_emailaddr"), assistantprincipal: tmpRS.fieldByName("assistantprincipal"), assistantprincipal_emailaddr: tmpRS.fieldByName("assistantprincipal_emailaddr"), antibullyingspecialist: tmpRS.fieldByName("antibullyingspecialist"), antibullyingspecialist_emailaddr: tmpRS.fieldByName("antibullyingspecialist_emailaddr"), websiteurl: tmpRS.fieldByName("websiteurl"), imagefile: tmpRS.fieldByName("imagefile"), logofile: tmpRS.fieldByName("logofile"), address1: tmpRS.fieldByName("address1"), address2: tmpRS.fieldByName("address2"), city: tmpRS.fieldByName("city"), state: tmpRS.fieldByName("state"), zipcode: tmpRS.fieldByName("zipcode"), phone: tmpRS.fieldByName("phone"), fax: tmpRS.fieldByName("fax"), longitude: tmpRS.fieldByName("longitude"), latitude: tmpRS.fieldByName("latitude"), id: tmpRS.fieldByName("id") }); Alloy.Globals.school.add(newSchool); tmpRS.next(); } tmpRS.close(); Alloy.Globals.school.saveAll(); } }
function saveCert() { timestamp = timestamp || Date.now(); var certifications = Alloy.createModel("certifications", { name: name, category: category, timestamp: "" + timestamp, passed: 1, comment: $.comment.value }); if (certifications.isValid()) { certifications.save(); $.addCertsWin.close({ animated: true }); alert("Save!"); Alloy.Collections.certifications.fetch(); } else { certifications.destroy(); alert("Failed"); } }
success: function(model, response) { Alloy.Globals.core.apiToken(response.UUID); profile = Alloy.createModel("profile"); profile.fetch({ success: function() { $.resetPasswordWrap.visible = false; $.resetPasswordWrap.height = 0; $.sendAdmin.visible = false; $.sendAdmin.height = 0; indicator.closeIndicator(); Alloy.Globals.profile = profile.toJSON(); Alloy.Globals.profile.supplier && Ti.App.fireEvent("account:itIsSupplier"); Alloy.Globals.profile.currency || null !== Alloy.Globals.profile.currency ? Ti.App.fireEvent("account:updateProfile") : chooseCurrency(); }, error: function() { indicator.closeIndicator(); } }); Alloy.Collections.adverts = Alloy.createCollection("advert"); Ti.App.fireEvent("account:showAccount"); },
function doCreate() { var user = Alloy.createModel("Users", { username: $.createUsername.getValue(), password: $.createPassword.getValue(), password_confirmation: $.createConfirm.getValue() }); user.save({}, { success: function() { doAuthorization({ username: $.createUsername.getValue(), password: $.createPassword.getValue() }); }, error: function() { Alert.dialog({ title: "エラー", message: "ユーザ登録に失敗しました" }); } }); }
$.btnAction.addEventListener("click", function() { if ("new" === status) { localCoupon = Alloy.createModel("CouponLocal"); localCoupon.set("CouponId", coupon.get("CouponId")); localCoupon.set("ItemId", JSON.stringify(coupon.get("ItemId"))); localCoupon.set("CouponName", coupon.get("CouponName")); localCoupon.set("CouponDesc", coupon.get("CouponDesc")); localCoupon.set("CouponExp", coupon.get("CouponExp")); localCoupon.set("CouponType", coupon.get("CouponType")); localCoupon.set("CouponVal", coupon.get("CouponVal")); localCoupon.set("UsageCount", coupon.get("UsageCount")); localCoupon.set("CouponImage", coupon.get("CouponImage")); localCoupon.set("ArrowImage", coupon.get("ArrowImage")); localCoupon.set("Status", "downloaded"); localCoupon.save(); Ti.App.fireEvent("coupondownloaded"); alert("Coupon is successfully downloaded to your device."); } else "downloaded" === status && ("Loyalty" === coupon.get("CouponType") || Ti.App.fireEvent("applycoupon", { coupondata: coupon.toJSON() })); });
updateAuthToken: function () { var username = this.get('username'); var password = this.get('password'); var authCode = this.get('authCode'); var account = this; var onSuccess = function (model) { if (model && model.getTokenAuth()) { account.resetPassword(); account.set({tokenAuth: model.getTokenAuth()}); } }; var onError = function (model) { account.resetPassword(); return account.trigger('error', account, 'ReceiveAuthTokenError'); }; var tokenAuth = Alloy.createModel('piwikTokenAuth'); tokenAuth.fetchToken(this, username, password, authCode, onSuccess, onError); }
function addProd() { var tactId = Alloy.Globals.tabgroup.getActiveTab(); var singleItem = Alloy.createModel("product", { name: $.nameField.value, type: $.typeField.value, price: $.priceField.value }); if ("" !== $.nameField.value && "" !== $.typeField.value && "" !== $.priceField.value) { products.add(singleItem); singleItem.save(); products.fetch(); $.nameField.value = ""; $.priceField.value = ""; $.nameField.blur(); $.typeField.blur(); $.priceField.blur(); } else { singleItem.destroy(); alert("Something is missing..."); } Alloy.Globals.tabgroup.setActiveTab(tactId); }
function saveSchedule() { var title = $.title.getValue(), startTime = $.startTime.getText(), endTime = $.endTime.getText(), content = $.memo.getValue(); $.title.blur(); $.memo.blur(); var scheduleDetailModel = Alloy.Collections.schedule_detail; var data = { schedule_id: func.getScheduleId(args["data"].day), title: title, start_time: startTime, end_time: endTime, content: content, img: Ti.API.selectedIcon }; func.writeLogImg(Ti.API.selectedIcon); args["data"].id && (data["id"] = args["data"].id); var detail = Alloy.createModel("schedule_detail", data); scheduleDetailModel.add(detail); detail.save(); openView("schedule", { date: args["data"].day }); }
onload: function() { json = JSON.parse(this.responseText); for (i = 0; i < json.length; i++) otroChild.push(Alloy.createModel("otro", { id: json[i].id, name: json[i].name, icon: json[i].image, url: json[i].url })); for (var i = 0; i < otroChild.length; i++) { var model = otroChild.at(i); id = model.get("id"); title = "" + model.get("name"); url = "" + model.get("url"); icon = "" + model.get("icon"); var newRow = Alloy.createController("otroChild", { id: id, title: title, url: url, icon: icon }); $._Tbl_otro.appendRow(newRow.getView()); } },
function doSignIn() { var signin = Alloy.createModel("signin", { login: $.login.value, password: $.password.value, appInstallId: Alloy.Globals.core.installId, appVersion: Ti.App.version, platformModel: Ti.Platform.model, platformVersion: Ti.Platform.version, platformOSName: Ti.Platform.osname, language: Ti.Locale.currentLanguage }); signin.localValidate(errorHandler) && signin.save({}, { success: function(model, response) { $.sendAdmin.visible = false; $.sendAdmin.height = 0; Alloy.Globals.core.apiToken(response.UUID); indicator.closeIndicator(); $.resetPasswordWrap.visible = false; $.resetPasswordWrap.height = 0; Ti.App.fireEvent("account:updateProfile"); Alloy.Collections.adverts = Alloy.createCollection("advert"); Ti.App.fireEvent("account:showAccount"); }, error: function(model, xhr) { indicator.closeIndicator(); if (xhr && xhr.Message) { Alloy.Globals.core.showErrorDialog(L(xhr.Message)); $.resetPasswordWrap.visible = true; $.resetPasswordWrap.height = Ti.UI.SIZE; } else if (xhr && !xhr.blocked) Alloy.Globals.core.showErrorDialog(L("not_signed")); else if (xhr && xhr.blocked) { $.sendAdmin.visible = true; $.sendAdmin.height = Ti.UI.SIZE; } } }); }
$.execute.addEventListener("click", function() { var message = Alloy.createWidget("be.k0suke.progresshud", "widget", { message: "--- response ----------\n\nobjects/show execute" }); $.container.add(message.getView()); message.on("click", function() { $.container.remove(message.getView()); }); var objects = Alloy.createModel("Objects"); objects.setClassname($.classname.getValue()); objects.show({ id: $.search.getValue(), success: function(model) { message.trigger("add", { message: "success: " + model.get("id") }); }, error: function(model, response) { message.trigger("add", { message: "error: " + response }); } }); });
Ti.Geolocation.getCurrentPosition(function(e) { var now = new Date().getTime; var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, String.format("%d-%d", now, Math.floor(1e3 * Math.random()))); file.write(evt.media); var favorites = Alloy.createCollection("favorite"); favorites.fetch(); var favorite = favorites.at(favorites.length - 1); var savePhoto = { path: file.nativePath, latitude: e.coords.latitude, longitude: e.coords.longitude, memo: favorite.get("name") }; var photo = Alloy.createModel("photo", savePhoto); photo.save(); Ti.API.info({ photo: photo }); Ti.Media.hideCamera(); Ti.App.fireEvent("app:update", { photo: photo }); $.takePicture.close(); });
function(_result) { var _response = _result.response; if (typeof _response.responseData !== 'undefined' && Object.prototype.toString.call( _response.responseData ) === '[object Array]') { Ti.API.debug('APP.getSyncPendingTransactions @success'); Ti.API.trace(JSON.stringify(_result)); var _transactionArray = []; for (var i = 0, j = 0; i < _response.responseData.length; i++) { var _transactionData = _response.responseData[i]; var _transaction = Alloy.createCollection('Transaction').getByRemoteId(_transactionData.idTransaction); if (!_transaction) { Ti.API.trace('APP.getSyncPendingTransactions @new transaction' + JSON.stringify(_transactionData)); _transaction = Alloy.createModel('Transaction'); _transaction.setStatus('SYNC_PENDING'); _transaction.setRemoteId(_transactionData.idTransaction); _transaction.setAmount(_transactionData.amount); _transaction.setTimestamp(_transactionData.timestamp); _transaction.setVenueName(_transactionData.venueName); _transaction.setCategoryId(_transactionData.idCategory); _transaction.setType(_transactionData.type); _transaction.setDescription(_transactionData.description); _transaction.setPhoneLL(_phoneLL); _transaction.save(); _transactionArray.push(_transaction.clone()); } } if (_transactionArray.length > 0) { POOL.addTransaction(_transactionArray); if (typeof _callback === 'function' ) { _callback(); } } } },
function saveToDo() { if ("string" == typeof $.iv.image) var filename = $.iv.image; else { var filename = Ti.Filesystem.applicationDataDirectory + $.titoloTxt.value.replace(/ /g, "_") + "_" + new Date().getTime() + ".jpg"; var f = Ti.Filesystem.getFile(filename); f.write($.iv.image.imageAsThumbnail(60, 0, 3)); } var newToDo = Alloy.createModel("ToDo", { title: $.titoloTxt.value, location: $.locationTxt.value, alarm: $.alarmSw.value, duedate: $.dateBtn.title, path: filename }); if (newToDo.isValid()) { newToDo.save(); Alloy.Collections.ToDo.add(newToDo); Alloy.Globals.tabgroup.setActiveTab(1); $.titoloTxt.value = ""; $.locationTxt.value = ""; $.alarmSw.value = false; $.dateBtn.title = "oggi"; $.iv.image = "/appicon.png"; } else alert("Inserire il titolo"); }
var Alloy = require("alloy"), _ = Alloy._, Backbone = Alloy.Backbone; Alloy.Models.User = Alloy.createModel("user"); Alloy.Globals.authHeader = function(user, apiKey) { var user = user || Ti.App.Properties.getString("username"), pass = apiKey || Ti.App.Properties.getString("password"), token = user.concat(":", pass), auth = "Basic ".concat(Ti.Utils.base64encode(token)); return auth.replace(/[\n\r]/g, ""); }; Alloy.createController("index");
function Controller() { function __alloyId8(e) { if (e && e.fromAdapter) return; __alloyId8.opts || {}; var models = __alloyId7.models; var len = models.length; var rows = []; _.each($.__views.column1.getRows(), function(r) { $.__views.column1.removeRow(r); }); for (var i = 0; len > i; i++) { var __alloyId5 = models[i]; __alloyId5.__transform = _.isFunction(__alloyId5.transform) ? __alloyId5.transform() : __alloyId5.toJSON(); $.__views.__alloyId6 = Ti.UI.createPickerRow({ title: __alloyId5.__transform.name, id: "__alloyId6" }); rows.push($.__views.__alloyId6); } _.each(rows, function(row) { $.__views.column1.addRow(row); }); } function __alloyId12(e) { if (e && e.fromAdapter) return; __alloyId12.opts || {}; var models = __alloyId11.models; var len = models.length; var rows = []; _.each($.__views.column2.getRows(), function(r) { $.__views.column2.removeRow(r); }); for (var i = 0; len > i; i++) { var __alloyId9 = models[i]; __alloyId9.__transform = doTransform(__alloyId9); $.__views.__alloyId10 = Ti.UI.createPickerRow({ title: __alloyId9.__transform.color, id: "__alloyId10" }); rows.push($.__views.__alloyId10); } _.each(rows, function(row) { $.__views.column2.addRow(row); }); } function doTransform(model) { var transform = model.toJSON(); transform.color = transform.color.toUpperCase(); return transform; } require("alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments)); this.__controllerPath = "index"; this.args = arguments[0] || {}; if (arguments[0]) { __processArg(arguments[0], "__parentSymbol"); __processArg(arguments[0], "$model"); __processArg(arguments[0], "__itemTemplate"); } var $ = this; var exports = {}; Alloy.Collections.instance("fruits"); Alloy.Collections.instance("colors"); $.__views.index = Ti.UI.createWindow({ backgroundColor: "#fff", fullscreen: false, exitOnClose: true, id: "index" }); $.__views.index && $.addTopLevelView($.__views.index); $.__views.picker = Ti.UI.createPicker({ id: "picker", top: 50, useSpinner: true }); $.__views.index.add($.__views.picker); var __alloyId4 = []; $.__views.column1 = Ti.UI.createPickerColumn({ id: "column1" }); __alloyId4.push($.__views.column1); var __alloyId7 = Alloy.Collections["fruits"] || fruits; __alloyId7.on("fetch destroy change add remove reset", __alloyId8); $.__views.column2 = Ti.UI.createPickerColumn({ id: "column2" }); __alloyId4.push($.__views.column2); var __alloyId11 = Alloy.Collections["colors"] || colors; __alloyId11.on("fetch destroy change add remove reset", __alloyId12); $.__views.picker.add(__alloyId4); exports.destroy = function() { __alloyId7 && __alloyId7.off("fetch destroy change add remove reset", __alloyId8); __alloyId11 && __alloyId11.off("fetch destroy change add remove reset", __alloyId12); }; _.extend($, $.__views); var fruits = [ "apple", "banana", "cherry", "blueberry", "orange", "pear" ]; var colors = [ "red", "yellow", "blue", "orange", "green", "white" ]; for (var i = 1, j = fruits.length; j > i; i++) { Alloy.createModel("fruits", { name: fruits[i] }).save(); Alloy.createModel("colors", { color: colors[i] }).save(); } Alloy.Collections.fruits.fetch(); Alloy.Collections.colors.fetch(); $.index.open(); _.extend($, exports); }