Permalink
Browse files

show ajax errors on new_comment_view

  • Loading branch information...
1 parent 6b81744 commit 38c7ce6014e6147c9d764c161f3b19a33e90cf20 @brownman committed Nov 17, 2012
@@ -15,5 +15,5 @@
<input type="submit" value="Submit">
</form>
-
+<input type='text' class='errors'>errors: </input>
</div>
@@ -1,4 +1,4 @@
-<div class="new-comment form span3">
+<div class="new_comment form span3">
<form class="field1" height='1em' >
@@ -15,5 +15,5 @@
<input type="submit" value="Submit">
</form>
-
+<input type='text' class='errors'>errors: </input>
</div>
@@ -19,9 +19,9 @@
<div id="collapseOne<%= post.id %>" class="accordion-body collapse">
<div class="accordion-inner">
- <div class="new_comment"></div>
+ <div class="new_comment">new_comment:</div>
- <div class="comments" ></div>
+ <div class="comments" >comments:</div>
</div>
@@ -1,7 +1,7 @@
<div class="accordion-heading">
<div class="accordion-toggle" data-toggle="collapse" data-parent="#posts-list" href="#collapseOne<%= post.id %>">
-<button class='open btn span2' >open</button>
+<button class='open btn span2' >fetch</button>
<a class="id"><%= post.id %></a>
<input class="title" value=<%= post.title %> >title: </input>
@@ -18,10 +18,12 @@
</div>
<div id="collapseOne<%= post.id %>" class="accordion-body collapse">
<div class="accordion-inner">
+<a>
+new_comment:
+</a>
+ <div class="new_comment">new_comment:</div>
- <div class="new_comment"></div>
-
- <div class="comments" ></div>
+ <div class="comments" >comments:</div>
</div>
@@ -9,7 +9,7 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
events:
"click .destroy" : "destroy"
- "dblclick .todo-array button": "push_index"
+ #"dblclick .todo-array button": "push_index"
"click .todo-array button": "whiteSpaceCheck"
@@ -22,7 +22,8 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
"keypress .title" : "updateOnEnter"
-
+
+
#"hover .todo-array button": "show_tooltip"
set_content: (e) ->
console.log(e)
@@ -31,19 +32,19 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
#this.$(".content");
console.log(input)
- @model.set({ content: input })
+ @model.save({ content: input })
#@render()
updateOnEnter: (e) ->
#this.trigger('somethingHappened')
- if e.keyCode is 13
+ #if e.keyCode is 13
console.log(e)
- @input = this.$(".title");
- console.log(@input)
+ input = this.$(".title");
+ console.log(input)
- @model.save({ title: @input.val() })
+ @model.save({ title: input.val() })
#$(@el).removeClass("editing")
initialize: () ->
@@ -94,6 +95,7 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
render: ->
+
listed2 = this.splitted2()
comment = @model.toJSON()
@@ -170,14 +172,17 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
whiteSpaceCheck: (ev) ->
item = ev.target
str = $(item).context.innerText
- if(str != '=')
+
+ tmp1 = $(item).hasClass("test1")
+ #alert(tmp1)
+ if(str != '=' && !tmp1)
_.delay(_.bind(this.something, item), @seconds * 1000 , 'logged later')
- $(item).toggleClass("test1")
+ $(item).addClass("test1")
else
@push_index(ev)
something: (msg) ->
- $(this).toggleClass("test1")
+ $(this).removeClass("test1")
set_delay: (ev) ->
@seconds = ev.target.value
@@ -9,7 +9,7 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
events:
"click .destroy" : "destroy"
- "dblclick .todo-array button": "push_index"
+ #"dblclick .todo-array button": "push_index"
"click .todo-array button": "whiteSpaceCheck"
@@ -22,7 +22,8 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
"keypress .title" : "updateOnEnter"
-
+
+
#"hover .todo-array button": "show_tooltip"
set_content: (e) ->
console.log(e)
@@ -38,12 +39,12 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
updateOnEnter: (e) ->
#this.trigger('somethingHappened')
- if e.keyCode is 13
+ #if e.keyCode is 13
console.log(e)
- @input = this.$(".title");
- console.log(@input)
+ input = this.$(".title");
+ console.log(input)
- @model.save({ title: @input.val() })
+ @model.save({ title: input.val() })
#$(@el).removeClass("editing")
initialize: () ->
@@ -94,6 +95,7 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
render: ->
+
listed2 = this.splitted2()
comment = @model.toJSON()
@@ -170,14 +172,17 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
whiteSpaceCheck: (ev) ->
item = ev.target
str = $(item).context.innerText
- if(str != '=')
+
+ tmp1 = $(item).hasClass("test1")
+ #alert(tmp1)
+ if(str != '=' && !tmp1)
_.delay(_.bind(this.something, item), @seconds * 1000 , 'logged later')
- $(item).toggleClass("test1")
+ $(item).addClass("test1")
else
@push_index(ev)
something: (msg) ->
- $(this).toggleClass("test1")
+ $(this).removeClass("test1")
set_delay: (ev) ->
@seconds = ev.target.value
@@ -16,7 +16,7 @@ class RailsBackboneRelational.Views.Comments.IndexView extends Backbone.View
#@options.comments.each(@update_span(num))
#.on('add2', this.alert_parent);
- @options.comments.bind('reset', @addAll)
+ #@options.comments.bind('reset', @addAll)
@options.comments.bind('add2', @add2_view)
#@options.comments.bind('remove', @addAll)
@@ -84,6 +84,7 @@ class RailsBackboneRelational.Views.Comments.IndexView extends Backbone.View
@$(".comments-list").append(view.render().el)
render: =>
+
comments = @options.comments.toJSON()
@num = @options.comments.length
@@ -42,10 +42,16 @@ class RailsBackboneRelational.Views.Comments.NewView extends Backbone.View
alert('error')
console.log(comment)
console.log(jqXHR)
- @model.set({errors: $.parseJSON(jqXHR.responseText)})
+ obj =
+ errors: $.parseJSON(jqXHR.responseText)
+ @model.set(obj)
+ str = obj.errors
+ @$('.errors').val(str)
+
#Backbone.history.navigate('', true);
)
+ #@render()
render: ->
$(@el).html(@template(@model.toJSON() ))
@@ -42,12 +42,19 @@ class RailsBackboneRelational.Views.Comments.NewView extends Backbone.View
alert('error')
console.log(comment)
console.log(jqXHR)
- @model.set({errors: $.parseJSON(jqXHR.responseText)})
+ obj =
+ errors: $.parseJSON(jqXHR.responseText)
+ #@model.set(obj)
+ #str = obj.errors
+ #@$('.errors').val(str)
+
#Backbone.history.navigate('', true);
)
+ #@render()
render: ->
$(@el).html(@template(@model.toJSON() ))
return this
+
@@ -22,8 +22,8 @@ class RailsBackboneRelational.Views.Posts.IndexView extends Backbone.View
#comments_view = new RailsBackboneRelational.Views.Comments.IndexView(abc)
#view.$(".comments").html(comments_view.render().el)
- #new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: post.get('comments'))
- #view.$(".new_comment").html(new_comment_view.render().el)
+ new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: post.get('comments'))
+ view.$(".new_comment").html(new_comment_view.render().el)
render: =>
$(@el).html(@template(posts: @options.posts.toJSON() ))
@@ -22,8 +22,8 @@ class RailsBackboneRelational.Views.Posts.IndexView extends Backbone.View
#comments_view = new RailsBackboneRelational.Views.Comments.IndexView(abc)
#view.$(".comments").html(comments_view.render().el)
- new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: post.get('comments'))
- view.$(".new_comment").html(new_comment_view.render().el)
+ #new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: post.get('comments'))
+ #view.$(".new_comment").html(new_comment_view.render().el)
render: =>
$(@el).html(@template(posts: @options.posts.toJSON() ))
@@ -32,14 +32,16 @@ class RailsBackboneRelational.Views.Posts.PostView extends Backbone.View
comments1 = post.get('comments')
num = comments1.length
view = @
+ console.log(view)
abc =
comments: comments1
ofer_length: num
comments_view = new RailsBackboneRelational.Views.Comments.IndexView(abc)
- view.$(".comments").html(comments_view.render().$el)
- new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: post.get('comments'))
- view.$(".new_comment").html(new_comment_view.render().el)
+ view.$(".comments").append(comments_view.render().$el)
+ new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: comments1)
+ view.$(".new_comment").append(new_comment_view.render().el)
+
destroy: () ->
@model.destroy()
@@ -77,6 +79,12 @@ class RailsBackboneRelational.Views.Posts.PostView extends Backbone.View
'length': num
)
$(@el).html(tmp)
+ view = $(@el)
+
+ comments1 = @model.get('comments')
+ #new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: comments1)
+ #view.find(".new_comment").html(new_comment_view.render().el)
+
return this
not_render2: =>
@@ -32,14 +32,16 @@ class RailsBackboneRelational.Views.Posts.PostView extends Backbone.View
comments1 = post.get('comments')
num = comments1.length
view = @
+ console.log(view)
abc =
comments: comments1
ofer_length: num
comments_view = new RailsBackboneRelational.Views.Comments.IndexView(abc)
- view.$(".comments").html(comments_view.render().$el)
- new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: post.get('comments'))
- view.$(".new_comment").html(new_comment_view.render().el)
+ view.$(".comments").append(comments_view.render().$el)
+ new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: comments1)
+ view.$(".new_comment").append(new_comment_view.render().el)
+
destroy: () ->
@model.destroy()
@@ -56,7 +58,7 @@ class RailsBackboneRelational.Views.Posts.PostView extends Backbone.View
#
updateOnEnter: (e) ->
- this.trigger('somethingHappened')
+ #this.trigger('somethingHappened')
if e.keyCode is 13
console.log(e)
@input = this.$(".title");
@@ -77,6 +79,12 @@ class RailsBackboneRelational.Views.Posts.PostView extends Backbone.View
'length': num
)
$(@el).html(tmp)
+ view = $(@el)
+
+ comments1 = @model.get('comments')
+ #new_comment_view = new RailsBackboneRelational.Views.Comments.NewView(collection: comments1)
+ #view.find(".new_comment").html(new_comment_view.render().el)
+
return this
not_render2: =>

0 comments on commit 38c7ce6

Please sign in to comment.