Skip to content

Automatically saving dirty objects to server #11

@lucasjans

Description

@lucasjans

What's the best way to detect when an esEntity is dirty and automatically saving it to the server?

I've created a simple extension to monitor and changes and update them call save.

        ko.extenders.save = function (target, option) {
            debugger;
            target.subscribe(function (newValue) {
                console.log(option + ": " + newValue);
                option.save();
            });
            return target;
        };

And I can extend any object that is a column. Here's an example to save when the name is changed

this.Name = ko.observable().extend({save: this});

But what I would really like to do is extend the "isDirty." Problem is, by the time it exists, it's already returned to the viewModel. I would rather not have to dynamically for-each through the viewModel after the data is applied to extend it. Is there a better way?

When I look in here:

es.objects.RevCoCompanies.prototype.customize(function () {
\\etc...
});

isDirty still doesn't exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions