Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Unefined Error in an empty file

$
0
0

Hello, I'm startet to learn Alloy but I stuck on this error. 'undefined' is not an object (evaluatiin '$model.__transform') at bookRow.js (line 10) Actually my bookRow.js is empty... The error from the console:

[ERROR] :  Script Error {
[ERROR] :      backtrace = "#0 () at file://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/5768C49A-936A-48A2-B6DA-7E8D83A43876/alloyoyo.app/alloy.js:72\n#1 Controller() at file://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/5768C49A-936A-48A2-B6DA-7E8D83A43876/alloyoyo.app/alloy/controllers/book1.js:16\n#2 () at file://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/5768C49A-936A-48A2-B6DA-7E8D83A43876/alloyoyo.app/alloy.js:72\n#3 Controller() at file://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/5768C49A-936A-48A2-B6DA-7E8D83A43876/alloyoyo.app/alloy/controllers/index.js:11\n#4 () at file://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/5768C49A-936A-48A2-B6DA-7E8D83A43876/alloyoyo.app/alloy.js:72";
[ERROR] :      line = 10;
[ERROR] :      message = "'undefined' is not an object (evaluating '$model.__transform')";
[ERROR] :      name = TypeError;
[ERROR] :      sourceId = 317758432;
[ERROR] :      sourceURL = "file://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/5768C49A-936A-48A2-B6DA-7E8D83A43876/alloyoyo.app/alloy/controllers/bookRow.js";
[ERROR] :  }
Here are the files:

View

index.xml

<Alloy>
    <TabGroup id="tabGroup">
        <Require src="book1" id="book1" />
        <Require src="book2" id="book2" />
    </TabGroup>
</Alloy>
book1.xml
<Alloy>
    <Collection src="Book" />
    <Tab id="book1Tab" title="Book1">
        <Window id="book1Win">
            <View>
                <TableView id="book1Table">
                    <Require src="bookRow"/>
                </TableView>
            </View>
        </Window>
    </Tab>
</Alloy>
bookRow.xml
<Alloy>
    <TableViewRow id="bookRow" dataId="" model="{alloy_id}">
        <ImageView id="img" image="{img}"/>
        <View class="vgroup">
            <Label id="title" text="{title}"/>
            <Label id="desc" text="{desc}"/>
        </View>
    </TableViewRow>
</Alloy>

Control

index.js

$.tabGroup.open();
$.tabGroup.setActiveTab(0); 
Alloy.Globals.tabGroup = $.tabGroup;
book1.js
if (!Ti.App.Properties.hasProperty('seeded')) {
    var xhr = Titanium.Network.createHTTPClient();
    xhr.onload = function() {
        Ti.API.info(this.responseText)
        var s = JSON.parse(this.responseText);
        for(var i = 0; i < s.length; i++) {
            var items = Alloy.createModel('book', { bookID: s[i].mID,
                                                    title: s[i].title, 
                                                    desc: s[i].desc, 
                                                    img: s[i].img });
            items.save();
            //alert(items.get('title'));
        }
        Ti.App.Properties.setString('seeded', 'yuppers');
 
        Alloy.Collections.Book.fetch();
        //alert(items.length);
    };
    xhr.open("POST", "http://127.0.0.1/books/test.php");
 
    xhr.send();
    Alloy.Collections.Book.fetch()
} else {
    Alloy.Collections.Book.fetch();
}
bookRow.js
//is empty

Model

Book.js

exports.definition = {
    config : {
        "columns" : {
            "bookID"   : "integer",
            "title"    : "text",
            "desc"     : "text",
            "img"      : "text"
        },
        "defaults" : {
            "bookID"   : "",
            "title"    : "",
            "desc"     : "",
            "img"      : ""
        },
        "adapter": {
            "type": "sql",
            "collection_name": "book"
        }
    },  
    extendModel: function(Model) {      
        _.extend(Model.prototype, {
            // extended functions and properties go here
        });
 
        return Model;
    },
    extendCollection: function(Collection) {        
        _.extend(Collection.prototype, {
            // extended functions and properties go here
        });
 
        return Collection;
    }
}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>