36 lines
1.2 KiB
Plaintext
36 lines
1.2 KiB
Plaintext
<div id="my_homework_sort">
|
|
<%= render :partial => 'users/my_homework_sort', :locals => {:type => type,:property => property,:order => @order,:search => search} %>
|
|
</div>
|
|
|
|
<div class="hw_search_box fr mr10">
|
|
<input class="hw_search-input" name="search" value='<%=search %>' placeholder="输入作业关键词进行搜索" type="text" >
|
|
<span class="hw_btn_search"></span>
|
|
</div>
|
|
<div class="cl"></div>
|
|
<script type="text/javascript">
|
|
var lastSearchCondition = '';
|
|
var count = 0;
|
|
function search_hws(e){
|
|
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
|
|
{
|
|
return;
|
|
}
|
|
lastSearchCondition = $(e.target).val().trim();
|
|
$.ajax({
|
|
url: '<%= url_for(:controller => 'users', :action => 'search_m_r_homeworks') %>'+'?name='+ e.target.value+'&type=<%=type %>&property=<%=property %>',
|
|
type:'get'
|
|
});
|
|
}
|
|
|
|
function throttle(method,context,e){
|
|
clearTimeout(method.tId);
|
|
method.tId=setTimeout(function(){
|
|
method.call(context,e);
|
|
},500);
|
|
}
|
|
|
|
//查询项目
|
|
$("input[name='search']").on('input', function (e) {
|
|
throttle(search_hws,window,e);
|
|
});
|
|
</script> |