Permalink
Browse files

form return error

  • Loading branch information...
1 parent 66cf882 commit 1e7712925065a73ef7fb5c41506f8c6e33c05468 @brownman committed Oct 29, 2012
@@ -3,6 +3,8 @@ class RailsBackboneRelational.Models.Comment extends Backbone.RelationalModel
defaults:
content: null
+ direction: true
+ title: null
#initialize: () ->
#console.log(this)
@@ -1,11 +1,17 @@
<div >
+
+
+<input height='1em' class='span12' type='text' value='<%= comment.title %>'></input>
+<input height='1em' class='span12' type='text' value='<%= comment.direction %>'></input>
+
<input height='1em' class='span12' type='text' value='<%= comment.content %>'></input>
+
<div class="btn-group todo-array " >
<%= listed2 %>
</div>
@@ -1,7 +1,13 @@
<div >
-<input class='span12' type='text' value='<%= comment.content %>'></input>
+
+
+<input height='1em' class='span12' type='text' value='<%= comment.title %>'></input>
+<input height='1em' class='span12' type='text' value='<%= comment.direction %>'></input>
+
+<input height='1em' class='span12' type='text' value='<%= comment.content %>'></input>
+
@@ -1,4 +1,9 @@
-<div class="field1 span3" height='1em' >
- <label for="content"> Add Draft:</label>
+<form class="field1 span3" height='1em' >
+ <label for="title"> Title:</label>
+ <input rows="1" wrap="hard" type="text" name="title" class="title" value="<%= title %>" />
+
+ <label for="content"> content:</label>
<textarea rows="1" wrap="hard" type="text" name="content" class="content" value="<%= content %>" />
-</div>
+
+<input type="submit" value="Submit">
+</form>
@@ -1,4 +1,9 @@
-<div class="field1 span12" height='1em' >
- <label for="content"> Add Draft:</label>
+<form class="field1 span3" height='1em' >
+ <label for="title"> Title:</label>
+ <input rows="1" wrap="hard" type="text" name="title" class="title" value="<%= title %>" />
+
+ <label for="content"> content:</label>
<textarea rows="1" wrap="hard" type="text" name="content" class="content" value="<%= content %>" />
-</div>
+
+<input type="submit" value="Submit">
+</form>
@@ -70,7 +70,7 @@ class RailsBackboneRelational.Views.Comments.CommentView extends Backbone.View
array = @model.split()
array[num...num] = ['=']
text = array.join("")
- @model.save(
+ @model.update(
content: text
)
@@ -4,7 +4,7 @@ class RailsBackboneRelational.Views.Comments.NewView extends Backbone.View
template: JST["backbone/templates/comments/new"]
events:
- "keypress .content": "save"
+ "submit .field1": "save"
constructor: (options) ->
super(options)
@@ -15,34 +15,25 @@ class RailsBackboneRelational.Views.Comments.NewView extends Backbone.View
)
save: (e) ->
- if e.keyCode == 13 and @$('.content').val() != ''
+ #e.keyCode == 13 and
+ if @$('.content').val() != ''
@model.unset("errors")
@model.set('content', @$('.content').val())
-
+ @model.set('title', @$('.title').val())
+ @model.set('direction', false)
@collection.create(@model.toJSON(),
success: (comment) =>
-
+ alert('success')
view = new RailsBackboneRelational.Views.Comments.CommentView({model : comment})
tmp = view.render().el
- #tmp0 = $(@.el).parent().parent().attr("id");
-
tmp1 = $(@.el).parent().parent().find('.comments-list')
- #.attr("class");
-
-
- #alert('id: ' + tmp0)
- #alert('class: ' + tmp1)
- #console.log(tmp0.class)
-
- tmp2 = $(@.el).parent().prev().find('.comments-list')
- console.log(tmp2)
$(tmp1).append(tmp)
-
- # $("#posts-list").prepend(view.render().el)
@$('.content').val('good')
+ @$('.title').val('good1')
error: (comment, jqXHR) =>
alert('error')
+ console.log(comment)
@model.set({errors: $.parseJSON(jqXHR.responseText)})
)
@@ -4,7 +4,7 @@ class RailsBackboneRelational.Views.Comments.NewView extends Backbone.View
template: JST["backbone/templates/comments/new"]
events:
- "keypress .content": "save"
+ "submit .field1": "save"
constructor: (options) ->
super(options)
@@ -15,34 +15,25 @@ class RailsBackboneRelational.Views.Comments.NewView extends Backbone.View
)
save: (e) ->
- if e.keyCode == 13 and @$('.content').val() != ''
+ #e.keyCode == 13 and
+ if @$('.content').val() != ''
@model.unset("errors")
@model.set('content', @$('.content').val())
-
+ @model.set('title', @$('.title').val())
+ @model.set('direction', false)
@collection.create(@model.toJSON(),
success: (comment) =>
-
+ alert('success')
view = new RailsBackboneRelational.Views.Comments.CommentView({model : comment})
tmp = view.render().el
- #tmp0 = $(@.el).parent().parent().attr("id");
-
tmp1 = $(@.el).parent().parent().find('.comments-list')
- #.attr("class");
-
-
- #alert('id: ' + tmp0)
- #alert('class: ' + tmp1)
- #console.log(tmp0.class)
-
- tmp2 = $(@.el).parent().prev().find('.comments-list')
- console.log(tmp2)
$(tmp1).append(tmp)
-
- # $("#posts-list").prepend(view.render().el)
@$('.content').val('good')
+ @$('.title').val('good1')
error: (comment, jqXHR) =>
- alert('error')
+ alert(comment)
+ console.log(comment)
@model.set({errors: $.parseJSON(jqXHR.responseText)})
)
@@ -11,6 +11,7 @@
</head>
<body width='100%'>
+<a href="https://github.com/brownman/book-splitter-backbone-bootstrap"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<div width='100%' class="container-fluid" >
@@ -27,4 +28,6 @@
</body>
+<footer>
+</footer>
</html>
@@ -6,9 +6,12 @@
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0 maximum-scale=1, user-scalable=no" />
+
+
</head>
<body width='100%'>
+<a href="https://github.com/makeusabrew/bootbox"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<div width='100%' class="container-fluid" >
@@ -25,4 +28,6 @@
</body>
+<footer>
+</footer>
</html>
@@ -0,0 +1,6 @@
+class AddDirectionToComments < ActiveRecord::Migration
+ def change
+ add_column :comments, :direction, :boolean
+
+ end
+end
@@ -0,0 +1,6 @@
+class AddTitleToComments < ActiveRecord::Migration
+ def change
+ add_column :comments, :title, :string
+
+ end
+end
View
@@ -11,13 +11,15 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120328010958) do
+ActiveRecord::Schema.define(:version => 20121029121212) do
create_table "comments", :force => true do |t|
- t.text "content"
+ t.string "content"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "post_id"
+ t.boolean "direction"
+ t.string "title"
end
create_table "posts", :force => true do |t|

0 comments on commit 1e77129

Please sign in to comment.