krawaller / kranium

Brains for Titanium
http://www.kraniumjs.com
Other
103 stars 13 forks source link

backbonedemo question #17

Open milescui opened 12 years ago

milescui commented 12 years ago
exports.Class = BackboneView.extend({
    type: 'tableview',
    editable: true, 

    events: {
        click: function(e){
            var model = todos.getByCid(e.rowData._modelCid);
            model.set({ hasCheck: !model.get('hasCheck') });
        },
        "delete": function(e){
            var model = todos.getByCid(e.rowData._modelCid);
            todos.remove(model);
        }
    }
});

How to not through the global variables obtained todos reference?

thanks /Miles

milescui commented 12 years ago
exports.Class = BackboneView.extend({
    type: 'tableview',
    editable: true, 
    events: {
        click: 'open',
        "delete": function(e){
            var model = todos.getByCid(e.rowData._modelCid);
            todos.remove(model);
        }
    },

    open: function(e) {
        var model = this.getCollection().getByCid(e.rowData._modelCid);
        model.set({ hasCheck: !model.get('hasCheck') });
    },
});

this.getCollection() throw exception run on iphone, but it success run on android.

iphone Exception info:

[WARN] Exception in event callback. {

expressionBeginOffset = 665;

expressionCaretOffset = 685;

expressionEndOffset = 694;

line = 28;

message = "Result of expression 'this.getCollection()' [null] is not an object.";

name = TypeError;

sourceId = 300567264;

}