Skip to content

Commit e130617

Browse files
committed
Merge pull request #1 from wannabeCitizen/master
Added Ajax for content submissions
2 parents 1c09199 + 2db6055 commit e130617

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.pyc
22
*.sw*
3+
*.DS_Store

static/js/jquery-2.1.1.min.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/js/textsubmit.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
$(document).ready(function(){
2+
3+
$(".button").click(function() {
4+
5+
var $input_data = $('#new_content : input');
6+
7+
var content_data = {}
8+
$input_data.each(function(){
9+
content_data[this.name] = $(this).val();
10+
});
11+
12+
$.ajax({
13+
url: '/api/v0/contentnode',
14+
method: 'PUT',
15+
data: content_data,
16+
success: function(data){
17+
console.log(data);
18+
},
19+
error: function(){
20+
console.log("Request Failed!");
21+
}
22+
23+
});
24+
});
25+
});

templates/edit_view.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<html>
22
<head>
3-
<script src="/static/js/markdown.min.js"></script>
3+
<script src="/static/js/markdown.min.js" />
4+
<script src="/static/jquery-2.1.1.min.js" />
5+
<script src="static/textsubmit.js" />
46

57
<link rel="stylesheet" type="text/css" href="/static/css/clearfix.css">
68
<link rel="stylesheet" type="text/css" href="/static/css/editor.css">

0 commit comments

Comments
 (0)