argon/model.js
function save(callback) {
            var model, request;

            model = this;

            this.constructor.dispatch('beforeSave', {
                data : {
                    model : this
                }
            });
            this.dispatch('beforeSave');

            this.isValid(function (isValid) {
                if (isValid) {
                    if (model.hasOwnProperty('id') && model.id !== '') {
                        request = {
                            action : 'update',
                            data : model,
                            model : model.constructor
                        };
                        model.constructor.storage.update(request, function updateCallback(data) {
                            model.constructor.dispatch('afterSave', {
                                data : {
                                    model : model
                                }
                            });

                            model.dispatch('afterSave');
                            if (callback) {
                                callback(data);
                            }
                        });
                    }
                    else {
                        request = {
                            action : 'create',
                            data : model,
                            model : model.constructor
                        };
                        model.constructor.storage.create(request, function createCallback(data) {
                            model.constructor.dispatch('afterSave', {
                                data : {
                                    model : model
                                }
                            });

                            model.dispatch('afterSave');
                            if (callback) {
                                callback(data);
                            }
                        });
                    }
                } else {
                    if (callback) {
                        callback(data);
                    }
                }
            });

        }
function save(callback) {
            var model, request;

            model = this;

            this.constructor.dispatch('beforeSave', {
                data : {
                    model : this
                }
            });
            this.dispatch('beforeSave');

            this.isValid(function (isValid) {
                if (isValid) {
                    if (model.hasOwnProperty('id') && model.id !== '') {
                        request = {
                            action : 'update',
                            data : model,
                            model : model.constructor
                        };
                        model.constructor.storage.update(request, function updateCallback(data) {
                            model.constructor.dispatch('afterSave', {
                                data : {
                                    model : model
                                }
                            });

                            model.dispatch('afterSave');
                            if (callback) {
                                callback(data);
                            }
                        });
                    }
                    else {
                        request = {
                            action : 'create',
                            data : model,
                            model : model.constructor
                        };
                        model.constructor.storage.create(request, function createCallback(data) {
                            model.constructor.dispatch('afterSave', {
                                data : {
                                    model : model
                                }
                            });

                            model.dispatch('afterSave');
                            if (callback) {
                                callback(data);
                            }
                        });
                    }
                } else {
                    if (callback) {
                        callback(data);
                    }
                }
            });

        }
function save ( callback ) { var model , request ; model = this ; this . constructor . dispatch ( 'beforeSave' , { data : { model : this } } ) ; this . dispatch ( 'beforeSave' ) ; this . isValid ( function ( isValid ) { if ( isValid ) { if ( model . hasOwnProperty ( 'id' ) && model . id !== '' ) { request = { action : 'update' , data : model , model : model . constructor } ; model . constructor . storage . update ( request , function updateCallback ( data ) { model . constructor . dispatch ( 'afterSave' , { data : { model : model } } ) ; model . dispatch ( 'afterSave' ) ; if ( callback ) { callback ( data ) ; } } ) ; } else { request = { action : 'create' , data : model , model : model . constructor } ; model . constructor . storage . create ( request , function createCallback ( data ) { model . constructor . dispatch ( 'afterSave' , { data : { model : model } } ) ; model . dispatch ( 'afterSave' ) ; if ( callback ) { callback ( data ) ; } } ) ; } } else { if ( callback ) { callback ( data ) ; } } } ) ; }
Saves the model to storage.
@method save <public>
@argument callback <required> [Function] function to manage response.
@return Noting.
Saves the model to storage .