Setting an object literal attribute with RequireJS does not trigger the passed callback function #52

Closed
ghost opened this Issue Jul 22, 2013 · 1 comment

Comments

Projects
None yet
1 participant
@ghost

ghost commented Jul 22, 2013

I am loading an object literal via RequireJs and passing it to an object which is at init time an "undefined" object:

define(["./bubbleChartModel", "../components/watch"], function (bubbleModel, watchJS) { 
var bubbleChartView = {

    model: {}, // doesn't work with model:undefined, as well

    initialize: function(modelObj) {
        var watch = watchJS.watch;
        var appDIV = "#chart-1";

        watch(bubbleChartView.model, function() {
            bubbleChartView.render();
        }); // passed 2,3 as depth but it did not work as well

        bubbleChartView.model = bubbleModel; //Render does not get called here!!!
    }

};

I tried to pass in numbers as depth but it did not work also. Is there any solution to this?

@melanke

This comment has been minimized.

Show comment
Hide comment
@melanke

melanke Sep 11, 2013

Owner

you should do this:

watch(bubbleChartView, "model", function() {
            bubbleChartView.render();
});
Owner

melanke commented Sep 11, 2013

you should do this:

watch(bubbleChartView, "model", function() {
            bubbleChartView.render();
});

@melanke melanke closed this Sep 11, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment