forked from BraindeadCrew/Bookmark-v2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all done except a "small" problem with bookmark creation and csrf pro…
…tection
- Loading branch information
Showing
8 changed files
with
103 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
class exports.BookmarkModel extends Backbone.Model | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,37 @@ | ||
BookmarkModel = require('models/bookmark_model').BookmarkModel | ||
|
||
class exports.BookmarkFormView extends Backbone.View | ||
tagName: 'div' | ||
el: $('#bookmark-form-modal') | ||
template: _.template($("#bookmark-form-modal-template").html()) | ||
events: | ||
"click #submit": "submitForm" | ||
render: -> | ||
$(@el).html(@template()) | ||
@ | ||
submitForm: (e) -> | ||
e.preventDefault() | ||
|
||
@ | ||
tagName: 'div' | ||
el: $('#bookmark-form-modal') | ||
template: _.template($("#bookmark-form-modal-template").html()) | ||
events: | ||
"submit": "submitForm" | ||
initialize: -> | ||
app.collections.bookmarks.bind "show-bookmark-form", @showBookmarkForm | ||
render: -> | ||
$(@el).html(@template()) | ||
@ | ||
submitForm: (e) -> | ||
e.preventDefault() | ||
id = $("#id").val() | ||
if _.isNumber id | ||
bookmark = app.collections.bookmarks.get $("#id").val() | ||
else | ||
bookmark = new BookmarkModel | ||
datas = | ||
link: $("#link").val() | ||
title: $("#title").val() | ||
description: $("#description").val() | ||
tags: $("#tags").val() | ||
csrf: $("#csrf").val() | ||
|
||
if !_.isNumber id | ||
app.collections.bookmarks.add bookmark | ||
bookmark.save datas, | ||
error: (model, errors) -> | ||
console.log "error", model, errors | ||
success: (model, errors) -> | ||
console.log "success", model, errors | ||
return | ||
showBookmarkForm: (bookmarkId) -> | ||
console.log "catchec", bookmarkId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters