{"action":"created","comment":{"url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/comments/44375377","id":44375377,"diff_hunk":"@@ -1,9 +1,59 @@\n // wait for DOM to load before running JS\n $(function() {\n \n-  // check to make sure JS is loaded\n-  console.log('JS is loaded!');\n-  \n-  // your code here\n+\t// check to make sure JS is loaded\n+\tconsole.log('JS is loaded!');\n+\n+\t// your code here\n+\n+\tvar booksUrl = \"https://super-crud.herokuapp.com/books\";\n+\tvar bookStore = [];\n+\tvar $booksList = $('#books-list');\n+\t\n+\t//compile handlebars template\n+\tvar source = $(\"#books-template\").html();\n+\tvar template = Handlebars.compile(source);\n+\n+\tfunction addBookToPage() {\n+\t\tdocument.getElementById(\"bookForm\").reset(); //use this to clear form\n+\t\tvar bookHtml = template({books: bookStore});\n+\t\t$booksList.append(bookHtml);\n+\t}\n+\t$.get(booksUrl, function(data) {\n+\t\tconsole.log(data);\n+\t\tbookStore = data.books;\n+\t\taddBookToPage();\n+\t}); \n+\n+\t$(\"form\").on(\"submit\", function(event){\n+\t\tevent.preventDefault();\n+\t\tvar addedBook = $(this).serialize();\n+\t\t$.post(booksUrl, addedBook, function(data) {\n+\t\t\tbookStore.push(data); //add new book to bookStore\n+\t\t\taddBookToPage(); //update new book to the Page\n+\t\t});\n+\t});\n+\t$(\"#books-list\").on(\"click\", \".edit-button\", function(){\n+\t\tvar getId = $(this).attr(\"id\");\n+\t\tconsole.log(getId);\n+\t\tvar $editForm = $(\"#form\"+ getId);\n+\t\tconsole.log(booksUrl + \"/\" + getId + \"/\");\n+\t\t$editForm.toggle();\n+\t\t$(\"#books-list\").on(\"submit\", $editForm, function(event) {\n+\t\t\tevent.preventDefault();\n+\t\t\tvar edittedBook = $editForm.serialize();\n+\t\t\tdocument.getElementById(\"form\" + getId).reset();\n+\t\t\t$.ajax({\n+\t\t\t\ttype: \"PUT\",\n+\t\t\t\turl: booksUrl + \"/\" + getId + \"/\",\n+\t\t\t\tdata: edittedBook,\n+\t\t\t\tsucess: function(data) {","path":"main.js","position":null,"original_position":54,"commit_id":"d908183f42506fa2ed65840ce5413ce13b1d77ca","original_commit_id":"2004e58bf98b3a0966e72580f7b1b11dac36f820","user":{"login":"tkhuynh","id":14950169,"avatar_url":"https://avatars.githubusercontent.com/u/14950169?v=3","gravatar_id":"","url":"https://api.github.com/users/tkhuynh","html_url":"https://github.com/tkhuynh","followers_url":"https://api.github.com/users/tkhuynh/followers","following_url":"https://api.github.com/users/tkhuynh/following{/other_user}","gists_url":"https://api.github.com/users/tkhuynh/gists{/gist_id}","starred_url":"https://api.github.com/users/tkhuynh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkhuynh/subscriptions","organizations_url":"https://api.github.com/users/tkhuynh/orgs","repos_url":"https://api.github.com/users/tkhuynh/repos","events_url":"https://api.github.com/users/tkhuynh/events{/privacy}","received_events_url":"https://api.github.com/users/tkhuynh/received_events","type":"User","site_admin":false},"body":"you are code saver :)","created_at":"2015-11-10T07:03:11Z","updated_at":"2015-11-10T07:03:11Z","html_url":"https://github.com/sf-wdi-24/ajax-book-app/pull/5#discussion_r44375377","pull_request_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/comments/44375377"},"html":{"href":"https://github.com/sf-wdi-24/ajax-book-app/pull/5#discussion_r44375377"},"pull_request":{"href":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/5","id":50217666,"html_url":"https://github.com/sf-wdi-24/ajax-book-app/pull/5","diff_url":"https://github.com/sf-wdi-24/ajax-book-app/pull/5.diff","patch_url":"https://github.com/sf-wdi-24/ajax-book-app/pull/5.patch","issue_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/issues/5","number":5,"state":"open","locked":false,"title":"Ajax Book App","user":{"login":"tkhuynh","id":14950169,"avatar_url":"https://avatars.githubusercontent.com/u/14950169?v=3","gravatar_id":"","url":"https://api.github.com/users/tkhuynh","html_url":"https://github.com/tkhuynh","followers_url":"https://api.github.com/users/tkhuynh/followers","following_url":"https://api.github.com/users/tkhuynh/following{/other_user}","gists_url":"https://api.github.com/users/tkhuynh/gists{/gist_id}","starred_url":"https://api.github.com/users/tkhuynh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkhuynh/subscriptions","organizations_url":"https://api.github.com/users/tkhuynh/orgs","repos_url":"https://api.github.com/users/tkhuynh/repos","events_url":"https://api.github.com/users/tkhuynh/events{/privacy}","received_events_url":"https://api.github.com/users/tkhuynh/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-10T06:05:48Z","updated_at":"2015-11-10T07:03:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"885100d69302357e3233a64e239afb12a8603f48","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/5/commits","review_comments_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/5/comments","review_comment_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/issues/5/comments","statuses_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/statuses/d908183f42506fa2ed65840ce5413ce13b1d77ca","head":{"label":"tkhuynh:master","ref":"master","sha":"d908183f42506fa2ed65840ce5413ce13b1d77ca","user":{"login":"tkhuynh","id":14950169,"avatar_url":"https://avatars.githubusercontent.com/u/14950169?v=3","gravatar_id":"","url":"https://api.github.com/users/tkhuynh","html_url":"https://github.com/tkhuynh","followers_url":"https://api.github.com/users/tkhuynh/followers","following_url":"https://api.github.com/users/tkhuynh/following{/other_user}","gists_url":"https://api.github.com/users/tkhuynh/gists{/gist_id}","starred_url":"https://api.github.com/users/tkhuynh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkhuynh/subscriptions","organizations_url":"https://api.github.com/users/tkhuynh/orgs","repos_url":"https://api.github.com/users/tkhuynh/repos","events_url":"https://api.github.com/users/tkhuynh/events{/privacy}","received_events_url":"https://api.github.com/users/tkhuynh/received_events","type":"User","site_admin":false},"repo":{"id":45859606,"name":"ajax-book-app","full_name":"tkhuynh/ajax-book-app","owner":{"login":"tkhuynh","id":14950169,"avatar_url":"https://avatars.githubusercontent.com/u/14950169?v=3","gravatar_id":"","url":"https://api.github.com/users/tkhuynh","html_url":"https://github.com/tkhuynh","followers_url":"https://api.github.com/users/tkhuynh/followers","following_url":"https://api.github.com/users/tkhuynh/following{/other_user}","gists_url":"https://api.github.com/users/tkhuynh/gists{/gist_id}","starred_url":"https://api.github.com/users/tkhuynh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkhuynh/subscriptions","organizations_url":"https://api.github.com/users/tkhuynh/orgs","repos_url":"https://api.github.com/users/tkhuynh/repos","events_url":"https://api.github.com/users/tkhuynh/events{/privacy}","received_events_url":"https://api.github.com/users/tkhuynh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tkhuynh/ajax-book-app","description":"Practice CRUD-ing books with AJAX and Handlebars","fork":true,"url":"https://api.github.com/repos/tkhuynh/ajax-book-app","forks_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/forks","keys_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/teams","hooks_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/hooks","issue_events_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/issues/events{/number}","events_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/events","assignees_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/assignees{/user}","branches_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/branches{/branch}","tags_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/tags","blobs_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/statuses/{sha}","languages_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/languages","stargazers_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/stargazers","contributors_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/contributors","subscribers_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/subscribers","subscription_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/subscription","commits_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/contents/{+path}","compare_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/merges","archive_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/downloads","issues_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/issues{/number}","pulls_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/pulls{/number}","milestones_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/milestones{/number}","notifications_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/labels{/name}","releases_url":"https://api.github.com/repos/tkhuynh/ajax-book-app/releases{/id}","created_at":"2015-11-09T18:56:48Z","updated_at":"2015-11-09T18:56:48Z","pushed_at":"2015-11-10T06:53:44Z","git_url":"git://github.com/tkhuynh/ajax-book-app.git","ssh_url":"git@github.com:tkhuynh/ajax-book-app.git","clone_url":"https://github.com/tkhuynh/ajax-book-app.git","svn_url":"https://github.com/tkhuynh/ajax-book-app","homepage":"","size":115,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sf-wdi-24:master","ref":"master","sha":"7868480101a9e08950fb703ad851aa9dca81c33c","user":{"login":"sf-wdi-24","id":15084798,"avatar_url":"https://avatars.githubusercontent.com/u/15084798?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-wdi-24","html_url":"https://github.com/sf-wdi-24","followers_url":"https://api.github.com/users/sf-wdi-24/followers","following_url":"https://api.github.com/users/sf-wdi-24/following{/other_user}","gists_url":"https://api.github.com/users/sf-wdi-24/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-wdi-24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-wdi-24/subscriptions","organizations_url":"https://api.github.com/users/sf-wdi-24/orgs","repos_url":"https://api.github.com/users/sf-wdi-24/repos","events_url":"https://api.github.com/users/sf-wdi-24/events{/privacy}","received_events_url":"https://api.github.com/users/sf-wdi-24/received_events","type":"Organization","site_admin":false},"repo":{"id":45653186,"name":"ajax-book-app","full_name":"sf-wdi-24/ajax-book-app","owner":{"login":"sf-wdi-24","id":15084798,"avatar_url":"https://avatars.githubusercontent.com/u/15084798?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-wdi-24","html_url":"https://github.com/sf-wdi-24","followers_url":"https://api.github.com/users/sf-wdi-24/followers","following_url":"https://api.github.com/users/sf-wdi-24/following{/other_user}","gists_url":"https://api.github.com/users/sf-wdi-24/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-wdi-24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-wdi-24/subscriptions","organizations_url":"https://api.github.com/users/sf-wdi-24/orgs","repos_url":"https://api.github.com/users/sf-wdi-24/repos","events_url":"https://api.github.com/users/sf-wdi-24/events{/privacy}","received_events_url":"https://api.github.com/users/sf-wdi-24/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sf-wdi-24/ajax-book-app","description":"Practice CRUD-ing books with AJAX and Handlebars","fork":false,"url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app","forks_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/forks","keys_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/teams","hooks_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/hooks","issue_events_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/issues/events{/number}","events_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/events","assignees_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/assignees{/user}","branches_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/branches{/branch}","tags_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/tags","blobs_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/statuses/{sha}","languages_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/languages","stargazers_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/stargazers","contributors_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/contributors","subscribers_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/subscribers","subscription_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/subscription","commits_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/contents/{+path}","compare_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/merges","archive_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/downloads","issues_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/issues{/number}","pulls_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls{/number}","milestones_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/milestones{/number}","notifications_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/labels{/name}","releases_url":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/releases{/id}","created_at":"2015-11-06T02:10:53Z","updated_at":"2015-11-06T02:12:30Z","pushed_at":"2015-11-10T06:59:01Z","git_url":"git://github.com/sf-wdi-24/ajax-book-app.git","ssh_url":"git@github.com:sf-wdi-24/ajax-book-app.git","clone_url":"https://github.com/sf-wdi-24/ajax-book-app.git","svn_url":"https://github.com/sf-wdi-24/ajax-book-app","homepage":"","size":345,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":6,"forks":14,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/5"},"html":{"href":"https://github.com/sf-wdi-24/ajax-book-app/pull/5"},"issue":{"href":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/issues/5"},"comments":{"href":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/sf-wdi-24/ajax-book-app/statuses/d908183f42506fa2ed65840ce5413ce13b1d77ca"}}}}