Skip to content

Commit

Permalink
view works with collection fetch, page builder controller returns fir…
Browse files Browse the repository at this point in the history
…st default model array with order, try-catch implemented on view templates
  • Loading branch information
diki committed Jun 23, 2012
1 parent d181bd5 commit 89eda40
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 19 deletions.
11 changes: 6 additions & 5 deletions kiMap/Scripts/app.js
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions 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;
}

});
10 changes: 9 additions & 1 deletion kiMap/Scripts/views/EditorView.js
Expand Up @@ -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;
},
Expand All @@ -25,7 +33,7 @@ var EditorView = Backbone.View.extend({
},

appendAfter: function () {

}


Expand Down
43 changes: 32 additions & 11 deletions kiMap/Views/s/Index.cshtml
Expand Up @@ -130,7 +130,10 @@
<div class="left-part widget-el span_3 break-word">
<div class="img-container widget-el">
<div class="img-wrapper widget-el" id="img-1">
<img src="<%=imgSrc1%>" />
<% try { %>
<img src="<%=imgSrc1%>" />
<% } catch(err) { %>
<% } %>
</div>
<form class="img-upload-form" method="post" action="/Images/upload" enctype="multipart/form-data">
<label class="cabinet">
Expand All @@ -145,7 +148,10 @@
<div class="left-part widget-el span_3 break-word">
<div class="img-container widget-el">
<div class="img-wrapper widget-el" id="img-2">
<img src="<%=imgSrc2%>" />
<% try { %>
<img src="<%=imgSrc2%>" />
<% } catch(err) { %>
<% } %>
</div>
<form class="img-upload-form" method="post" action="/Images/upload" enctype="multipart/form-data">
<label class="cabinet">
Expand All @@ -160,7 +166,10 @@
<div class="left-part widget-el span_3 break-word">
<div class="img-container widget-el">
<div class="img-wrapper widget-el" id="img-3">
<img src="<%=imgSrc3%>" />
<% try { %>
<img src="<%=imgSrc3%>" />
<% } catch(err) { %>
<% } %>
</div>
<form class="img-upload-form" method="post" action="/Images/upload" enctype="multipart/form-data">
<label class="cabinet">
Expand All @@ -180,7 +189,10 @@
<div class="left-part span_3 widget-el">
<div class="img-container widget-el">
<div class="img-wrapper widget-el" id="img-1">
<img src="<%=imgSrc1%>" />
<% try { %>
<img src="<%=imgSrc1%>" />
<% } catch(err) { %>
<% } %>
</div>
<form class="img-upload-form" method="post" action="/Images/upload" enctype="multipart/form-data">
<label class="cabinet">
Expand All @@ -192,7 +204,10 @@
<div class="left-part span_3 widget-el">
<div class="img-container widget-el">
<div class="img-wrapper widget-el" id="img-2">
<img src="<%=imgSrc2%>" />
<% try { %>
<img src="<%=imgSrc2%>" />
<% } catch(err) { %>
<% } %>
</div>
<form class="img-upload-form" method="post" action="/Images/upload" enctype="multipart/form-data">
<label class="cabinet">
Expand All @@ -204,7 +219,10 @@
<div class="left-part span_3 widget-el">
<div class="img-container widget-el">
<div class="img-wrapper widget-el" id="img-3">
<img src="<%=imgSrc3%>" />
<% try { %>
<img src="<%=imgSrc3%>" />
<% } catch(err) { %>
<% } %>
</div>
<form class="img-upload-form" method="post" action="/Images/upload" enctype="multipart/form-data">
<label class="cabinet">
Expand All @@ -223,7 +241,10 @@
<div class="left-part left-part-floater span_4 widget-el">
<div class="img-container">
<div class="img-wrapper widget-el" id="img-1">
<img src="<%=imgSrc1%>" />
<% try { %>
<img src="<%=imgSrc1%>" />
<% } catch(err) { %>
<% } %>
</div>
<form class="img-upload-form" method="post" action="/Images/upload" enctype="multipart/form-data">
<label class="cabinet">
Expand All @@ -235,12 +256,12 @@

<div class="left-part left-part-floater span_12 bio-container widget-el">
<h2 class="widget-el"><%=title%></h2>
<% if(fb!==undefined) { %>
<% try { %>
<h4 class="widget-el"><%=fb%></h4>
<% } %>
<% if(tw!==undefined) { %>
<% } catch(err) {} %>
<% try { %>
<h4 class="widget-el"><%=tw%></h4>
<% } %>
<% } catch(err) {} %>
<ul class="bio-list">
<li class="widget-el"><%=address%></li>
<li class="widget-el"><%=phone%></li>
Expand Down

0 comments on commit 89eda40

Please sign in to comment.