Setting an object literal attribute with RequireJS does not trigger the passed callback function
opened this issue · comments
Deleted user commented
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?
Gil Lopes Bueno commented
you should do this:
watch(bubbleChartView, "model", function() {
bubbleChartView.render();
});