diff --git a/README.md b/README.md index b5379e4..29eee7d 100644 --- a/README.md +++ b/README.md @@ -285,15 +285,17 @@ $(function () { ```javascript ko.components.register('dashboard-grid', { viewModel: { - createViewModel: function (params, componentInfo) { - var ViewModel = function (params, componentInfo) { + createViewModel: function (controller, componentInfo) { + var ViewModel = function (controller, componentInfo) { var grid = null; - this.widgets = params.widgets; + this.widgets = controller.widgets; this.afterAddWidget = function (items) { _.each(items, function (item) { item = $(item); + if (item.data('_gridstack_node') || item[0].nodeType != 1) + return; if (grid == null) { grid = $(componentInfo.element).find('.grid-stack').gridstack({ @@ -307,23 +309,34 @@ ko.components.register('dashboard-grid', { }); }, this); }; - }; - return new ViewModel(params, componentInfo); + return new ViewModel(controller, componentInfo); } }, - template: [ - '