How to use the alloy.createModel function in alloy

To help you get started, we’ve selected a few alloy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appcelerator / alloy / test / apps / testing / ALOY-440 / _generated / mobileweb / alloy / controllers / index.js View on Github external
__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);
}
github appcelerator / alloy / test / apps / testing / ALOY-503 / _generated / android / alloy / controllers / index.js View on Github external
_.extend($, $.__views);
    if (!Ti.App.Properties.hasProperty("seeded")) {
        var pins = [ {
            title: "Appcelerator",
            latitude: 37.3892876,
            longitude: -122.0502364
        }, {
            title: "SETI Institute",
            latitude: 37.386697,
            longitude: -122.052028
        }, {
            title: "Someplace nearby",
            latitude: 37.3880608,
            longitude: -122.0559039
        } ];
        for (var i = 0, j = pins.length; j > i; i++) Alloy.createModel("pins", {
            title: pins[i].title,
            latitude: pins[i].latitude,
            longitude: pins[i].longitude
        }).save();
        Ti.App.Properties.setString("seeded", "yuppers");
    }
    Alloy.Collections.pins.fetch();
    $.index.open();
    _.extend($, exports);
}
github appcelerator / alloy / test / apps / testing / ALOY-829 / _generated / windows / alloy / controllers / index.js View on Github external
function showInfo(e) {
        var modelId = e.section.getItemAt(e.itemIndex).properties.modelId;
        var model = Alloy.createModel("info");
        model.fetch({
            id: modelId
        });
        var pass = JSON.stringify(model.attributes) === JSON.stringify({
            id: modelId,
            info: "info " + modelId
        });
        Ti.API.info('Assert single info model returned with "{id:' + modelId + '}": ' + (pass ? green("OK") : red("FAIL")));
    }
    require("alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments));
github matomo-org / matomo-mobile-2 / specs / models / piwikWebsites_spec.js View on Github external
it('should return website properties', function() {

        var website = Alloy.createModel('piwikWebsites', getFakeWebsite());

        expect(website.getName()).toEqual('virtual-drums.com');
        expect(website.getSiteId()).toEqual(3);
        expect(website.id).toEqual(3);
    });
});
github BOXOUT-THINKERS / TiOpenChat / Resources / iphone / alloy / controllers / chat / chatRoom.js View on Github external
function _addUnregisterFriend(extendData) {
        Ti.API.debug("_addUnregisterFriend");
        var frinedInfo = friendContactM.getUserInfo();
        Alloy.Globals.startWaiting("c_waitingMsgDefault");
        var friendContactData = {
            User_objectId: currentUserId,
            isUnregister: false,
            User_objectId_To: null,
            mainPhone: frinedInfo.mainPhone,
            User_object_To: null
        };
        extendData && _.extend(friendContactData, extendData);
        var tempContactM = Alloy.createModel("contacts");
        tempContactM.save(friendContactData, {
            success: function() {
                friendContactM.set({
                    objectId: tempContactM.id
                }, {
                    change: false
                });
                friendContactM.fetch({
                    urlparams: {
                        include: "User_object_To"
                    },
                    success: function() {
                        contactsColllection.add(friendContactM);
                        Alloy.Globals.stopWaiting();
                    },
                    error: function(e, e2) {
github matomo-org / matomo-mobile-2 / specs / models / piwikProcessedReport_spec.js View on Github external
beforeEach(function() {
        searchEngineModel = Alloy.createModel('piwikProcessedReport', getSearchEngineEntry());
        visitsOfDayModel  = Alloy.createModel('piwikProcessedReport', getVisitsOfDayByWeekEntry());
    });
github BOXOUT-THINKERS / TiOpenChat / Resources / iphone / alloy / models / Contacts.js View on Github external
data2.email = model2.get("email");
                        return _.isEqual(data1, data2);
                    }
                    Alloy.Globals.loginC.doingSyncAddress = true;
                    var singleValue = [ "firstName", "middleName", "lastName", "fullName" ];
                    var multiValue = [ "email", "phone" ];
                    var people = Ti.Contacts.getAllPeople();
                    Ti.API.debug("[SyncAddressBook] Total contacts : ", people.length, " / Fetched Collections : ", thisCollection.length);
                    var createCount = 0;
                    var updateCount = 0;
                    var updateArrary = [];
                    var contactArray = [];
                    var parseCreateArary = [];
                    for (var i = 0, ilen = people.length; ilen > i; i++) {
                        var person = people[i];
                        var contactsModel = new Alloy.createModel("contacts");
                        contactsModel.set("User_objectId", Alloy.Globals.user.get("id"));
                        var phoneModel = new Backbone.Model(person["phone"]);
                        var mainPhone = "";
                        phoneModel.get("mobile") && phoneModel.get("mobile")[0].length >= 10 ? mainPhone = phoneModel.get("mobile")[0] : phoneModel.get("iphone") && phoneModel.get("iphone")[0].length >= 10 ? mainPhone = phoneModel.get("iphone")[0] : phoneModel.get("main") && phoneModel.get("main")[0].length >= 10 ? mainPhone = phoneModel.get("main")[0] : phoneModel.get("home") && phoneModel.get("home")[0].length >= 10 ? mainPhone = phoneModel.get("home")[0] : phoneModel.get("work") && phoneModel.get("work")[0].length >= 10 ? mainPhone = phoneModel.get("work")[0] : phoneModel.get("other") && phoneModel.get("other")[0].length >= 10 && (mainPhone = phoneModel.get("other")[0]);
                        if ("" != mainPhone) {
                            mainPhone = "+" == mainPhone.substring(0, 1) ? "+" + (1 * Alloy.Globals.util.getNumberOnly(mainPhone)).toString() : Alloy.Globals.user.get("attributes")["local"] + (1 * Alloy.Globals.util.getNumberOnly(mainPhone)).toString();
                            if (mainPhone.length >= 12) {
                                contactsModel.set("mainPhone", mainPhone);
                                for (var j = 0, jlen = singleValue.length; jlen > j; j++) contactsModel.set(singleValue[j], person[singleValue[j]]);
                                for (var j = 0, jlen = multiValue.length; jlen > j; j++) contactsModel.set(multiValue[j], JSON.stringify(person[multiValue[j]]));
                                contactArray.push(contactsModel.toJSON());
                            }
                        }
                    }
                    contactArray = _.sortBy(contactArray, "mainPhone");
                    var beforeMainPhone = "";
github matomo-org / matomo-mobile-2 / specs / models / piwikVersion_spec.js View on Github external
beforeEach(function() {
        piwikVersion = Alloy.createModel('piwikVersion');
        piwik1Dot1Version = Alloy.createModel('piwikVersion', {value: '1.11.1'});
        piwik1Dot1Version = Alloy.createModel('piwikVersion', {value: '1.12'});
        piwik1Dot1Version = Alloy.createModel('piwikVersion', {value: '2.0'});
    });
github BOXOUT-THINKERS / TiOpenChat / Resources / iphone / alloy / controllers / setting / hideFriendManage.js View on Github external
function cancleBan(contactM) {
        hideContactsCol.remove(contactM, {
            remove: false
        });
        drawHideFriend();
        var tempContactM = Alloy.createModel("contacts");
        tempContactM.save({
            objectId: contactM.id,
            isHidden: false
        }, {
            success: function() {
                contactM.set({
                    isHidden: false
                }, {
                    change: "false"
                });
            },
            error: function() {
                hideContactsCol.add(contactM, {
                    add: false
                });
                drawHideFriend();