Commit 424f1e44 by Afzal Wali Committed by Muhammad Shoaib

clear search text.

parent 8f061921
......@@ -18,8 +18,8 @@ var edx = edx || {};
this.initial_url = this.collection.url;
this.attempt_url = this.model.url;
this.collection.url = this.initial_url + this.course_id;
this.inSearchMode = true;
this.searchString = "abc";
this.inSearchMode = false;
this.searchText = "";
/* re-render if the model changes */
this.listenTo(this.collection, 'change', this.collectionChanged);
......@@ -30,21 +30,28 @@ var edx = edx || {};
events: {
"click .remove-attempt": "onRemoveAttempt",
'click li > a.target-link': 'getPaginatedAttempts',
'click .search-attempts > span.search': 'searchAttempts'
'click .search-attempts > span.search': 'searchAttempts',
'click .search-attempts > span.clear-search': 'clearSearch'
},
searchAttempts: function(event) {
var searchText = $('#search_attempt_id').val();
debugger;
if (searchText !== "") {
this.inSearchMode = true;
this.searchString = searchText;
this.searchText = searchText;
this.collection.url = this.initial_url + this.course_id + "/search/" + searchText;
this.hydrate();
event.stopPropagation();
event.preventDefault();
}
},
clearSearch: function(event) {
this.inSearchMode = false;
this.searchText = "";
this.collection.url = this.initial_url + this.course_id;
this.hydrate();
event.stopPropagation();
event.preventDefault();
},
getPaginatedAttempts: function(event) {
var target = $(event.currentTarget);
var url = target.data('target-url');
......
......@@ -2,9 +2,13 @@
<section class="content">
<div class="top-header">
<div class='search-attempts'>
<input type="text" id="search_attempt_id" placeholder="e.g johndoe or john.do@gmail.com" />
<input type="text" id="search_attempt_id" placeholder="e.g johndoe or john.do@gmail.com"
<% if (inSearchMode) { %>
value="<%= searchText %>"
<%} %>
/>
<span class="search"><i class="fa fa-search"></i></span>
<span><i class="fa fa-refresh"></i></i></span>
<span class="clear-search"><i class="fa fa-remove"></i></i></span>
</div>
<ul class="pagination">
<% if (!pagination_info.has_previous){ %>
......
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