简体   繁体   中英

How do i find if the model is new or has no property in it : backbone

This is my backbone model and collection:

var myModel = Backbone.Model.extend({ });

var myCollection = Backbone.Collection.extend({
    model :  myModel,
});

when i do new of model

debitRow = new myModel();

this will have no property or value in it.

now how do i find that the model is empty or not

I have made it to work like the following,

if(_.isEmpty(debitRow.attributes)){
                        // do your stuff
                    }

您是否尝试过.isNew(),请参见此处的文档

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM