link add search pg

adam
aundus 2021-03-18 20:52:10 -04:00
parent 616d118440
commit 214c37a8f0
4 changed files with 12 additions and 3 deletions

View File

@ -21,4 +21,13 @@
}
})
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
if(urlParams.has('addId')){
// console.log(urlParams.get('addId'))
$('#id_bookid').val(urlParams.get('addId'))
}
})(jQuery)

View File

@ -11,7 +11,7 @@
<form class="add-form" action="/bookshelves/{{bookshelfId}}" method="post">
{% csrf_token %}
{{ form }}
<input type="submit" value="Add Book">
<input type="submit" id="add-book-btn" value="Add Book">
</form>
<p class="form-help">Or search for a book to add <a href="/bookshelves/{{bookshelfId}}/search">here</a></p>
{% endif %}

View File

@ -16,7 +16,7 @@
<ul>
{% for book in books %}
<li class="bookshelf" id="book-{{ book.id }}">
<a href="https://www.gutenberg.org/ebooks/{{ book.id }}">{{ book.title }}</a>
<a href="/bookshelves/{{bookshelfId}}?addId={{ book.id }}">{{ book.title }}</a>
</li>
{% endfor %}
</ul>

View File

@ -86,7 +86,7 @@ def searchBooksToAdd(request, bookshelfId):
context['form'] = BookSearchForm()
# redirect to a new URL:
return render(request, 'search.html', context=context)
return render(request, 'searchToAdd.html', context=context)
# if a GET (or any other method) we'll create a blank form
else: