Commit 20926e83 by Rocky Duan

fixed ajax retrieved search bar in forum view

parent cacd58ca
......@@ -43,12 +43,10 @@ def render_discussion(request, course_id, threads, discussion_id=None, \
'forum': 'discussion/_forum.html',
}[discussion_type]
"""base_url = {
base_url = {
'inline': (lambda: reverse('django_comment_client.forum.views.inline_discussion', args=[course_id, discussion_id])),
'forum': (lambda: reverse('django_comment_client.forum.views.forum_form_discussion', args=[course_id, discussion_id])),
}[discussion_type]()"""
base_url = reverse('django_comment_client.forum.views.inline_discussion', args=[course_id, discussion_id])
}[discussion_type]()
annotated_content_info = {thread['id']: get_annotated_content_info(thread, request.user.id) for thread in threads}
......@@ -116,13 +114,17 @@ def forum_form_discussion(request, course_id, discussion_id):
threads, query_params = get_threads(request, course_id, discussion_id)
content = render_forum_discussion(request, course_id, threads, discussion_id=discussion_id, \
query_params=query_params)
context = {
'csrf': csrf(request)['csrf_token'],
'course': course,
'content': content,
'accordion': render_accordion(request, course, discussion_id),
}
return render_to_response('discussion/index.html', context)
if request.is_ajax():
return utils.HtmlResponse(content)
else:
context = {
'csrf': csrf(request)['csrf_token'],
'course': course,
'content': content,
'accordion': render_accordion(request, course, discussion_id),
}
return render_to_response('discussion/index.html', context)
def get_annotated_content_info(content, user_id):
......
......@@ -122,13 +122,7 @@ initializeFollowDiscussion = (discussion) ->
Discussion.bindLocalEvents $local,
"submit .search-wrapper-forum>.discussion-search-form": (event) ->
event.preventDefault()
text = $local(".search-input").val()
isSearchWithinBoard = $local(".discussion-search-within-board").is(":checked")
handleSearch(text, isSearchWithinBoard)
"submit .search-wrapper-inline>.discussion-search-form": (event) ->
"submit .search-wrapper>.discussion-search-form": (event) ->
event.preventDefault()
handleAjaxSearch(this)
......@@ -138,7 +132,7 @@ initializeFollowDiscussion = (discussion) ->
"click .discussion-search-link": ->
handleAjaxSearch(this)
"click .discussion-inline-sort-link": ->
"click .discussion-sort-link": ->
handleAjaxSort(this)
$discussion.children(".discussion-paginator").find(".discussion-inline-page-link").click ->
......
......@@ -5,7 +5,7 @@
<div class="discussion-title-wrapper">
<a class="discussion-title" href="javascript:void(0)">Discussion</a>
</div>
<div class="search-wrapper-forum">
<div class="search-wrapper">
<%include file="_search_bar.html" />
</div>
<div class="search-within">
......
......@@ -2,7 +2,7 @@
<section class="discussion inline-discussion" _id="${discussion_id}">
<div class="discussion-non-content">
<div class="search-wrapper-inline">
<div class="search-wrapper-inline search-wrapper">
<%include file="_search_bar.html" />
</div>
<div class="discussion-new-post control-button" href="javascript:void(0)">New Post</div>
......
......@@ -9,7 +9,7 @@
%>
<%def name="link_to_page(_page, text)">
<a class="discussion-page-link discussion-inline-page-link" href="javascript:void(0)" page-url="${url_for_page(_page)}">${text}</a>
<a class="discussion-page-link" href="javascript:void(0)" page-url="${url_for_page(_page)}">${text}</a>
</%def>
<%def name="div_page(_page)">
......
......@@ -20,7 +20,7 @@
def url_for_sort(key, order):
return base_url + '?' + urlencode(merge(query_params, {'page': 1, 'sort_key': key, 'sort_order': order}))
%>
<a class="discussion-sort-link discussion-inline-sort-link ${cls}" href="javascript:void(0)" sort-url="${url_for_sort(key, order)}">${title}</a>
<a class="discussion-sort-link ${cls}" href="javascript:void(0)" sort-url="${url_for_sort(key, order)}">${title}</a>
</%def>
<div class="discussion-sort">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment