Skip to content

Generating an observe block in created or ready doesn't bind #448

Closed
@garytryan

Description

I want to generate the observe block in the created or ready callback. However, the handlers don't seem to get called.

Here's the code:

    created: function () {
        var viewData = {
            type: 'Pikachu',
            name: 'Gary'
        };

        // iterate over view data
        for (prop in viewData) {
            //set the property
            this[prop] = viewData[prop];


            var handlerName = 'update' + prop

            // set add the property to the observe block
            this.observe[prop] = handlerName;

            // set the handler
            this[handlerName] = function (valueWas, valueIs) {
                console.log('you have changed ' + prop + ' to ' valueIs);
            };
        }
    },

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions