From 89eda404aa84d5a3eb88c75ea2a9f674cfbba3e0 Mon Sep 17 00:00:00 2001 From: mdikici Date: Sat, 23 Jun 2012 04:41:12 +0300 Subject: [PATCH] view works with collection fetch, page builder controller returns first default model array with order, try-catch implemented on view templates --- kiMap/Scripts/app.js | 11 ++--- .../Scripts/collections/WidgetsCollection.js | 9 +++- kiMap/Scripts/views/EditorView.js | 10 ++++- kiMap/Views/s/Index.cshtml | 43 ++++++++++++++----- 4 files changed, 54 insertions(+), 19 deletions(-) diff --git a/kiMap/Scripts/app.js b/kiMap/Scripts/app.js index 0709454..2641520 100644 --- a/kiMap/Scripts/app.js +++ b/kiMap/Scripts/app.js @@ -48,11 +48,12 @@ $(function () { }); window.widgetsCollection = new WidgetsCollection(); - widgetsCollection.add(DefaultHeaderModel); - widgetsCollection.add(DefaultTextModel); - widgetsCollection.add(DefaultTitleModel); - widgetsCollection.add(DefaultGalleryModel); - widgetsCollection.add(DefaultBioModel); +// widgetsCollection.add(DefaultHeaderModel); +// widgetsCollection.add(DefaultTextModel); +// widgetsCollection.add(DefaultTitleModel); +// widgetsCollection.add(DefaultGalleryModel); +// widgetsCollection.add(DefaultBioModel); + window.editorView = new EditorView({ collection: widgetsCollection diff --git a/kiMap/Scripts/collections/WidgetsCollection.js b/kiMap/Scripts/collections/WidgetsCollection.js index 966a18e..0a7efa2 100644 --- a/kiMap/Scripts/collections/WidgetsCollection.js +++ b/kiMap/Scripts/collections/WidgetsCollection.js @@ -1,5 +1,10 @@ var WidgetsCollection = Backbone.Collection.extend({ - model: WidgetModel - + model: WidgetModel, + url: "/build/page", + + parse: function (resp) { + return resp.data; + } + }); \ No newline at end of file diff --git a/kiMap/Scripts/views/EditorView.js b/kiMap/Scripts/views/EditorView.js index e43aa49..cf334af 100644 --- a/kiMap/Scripts/views/EditorView.js +++ b/kiMap/Scripts/views/EditorView.js @@ -9,11 +9,19 @@ var EditorView = Backbone.View.extend({ //with this variable i will obtain view of last click of add button this.selectedWidget = false; + //initial rendering of widgets data coming from server + this.collection.on("reset", this.render); + + //on addition of new widget this view will insert new widget view after selectedwidget + //also order numbers of widge models in colllection should be updated + this.collection.on("add", this.addWidget); this.render(); }, + render: function () { + console.log("eveeeeeet"); this.collection.each(this.appendWidget); return this; }, @@ -25,7 +33,7 @@ var EditorView = Backbone.View.extend({ }, appendAfter: function () { - + } diff --git a/kiMap/Views/s/Index.cshtml b/kiMap/Views/s/Index.cshtml index 49f6fb4..01cb753 100644 --- a/kiMap/Views/s/Index.cshtml +++ b/kiMap/Views/s/Index.cshtml @@ -130,7 +130,10 @@
- + <% try { %> + + <% } catch(err) { %> + <% } %>