socialforge/app/views/users/_homework_search_input.html...

29 lines
963 B
Plaintext
Raw Normal View History

2016-03-04 10:34:04 +08:00
<input type="text" name="search" placeholder="输入作业、老师姓名的关键词进行搜索" class="subject-pop-search fr" />
2016-01-27 17:26:57 +08:00
<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({
2016-03-03 17:04:38 +08:00
url: '<%= url_for(:controller => 'users', :action => 'user_search_homeworks') %>'+'?name='+ e.target.value+'&type=<%=type %>&is_import=<%=is_import %>',
2016-01-27 17:26:57 +08:00
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>