Skip to content

Instantly share code, notes, and snippets.

@3014zhangshuo
Created August 26, 2017 02:08
Show Gist options
  • Save 3014zhangshuo/a7126fc93b2c6ec7e84aaad17c22a192 to your computer and use it in GitHub Desktop.
Save 3014zhangshuo/a7126fc93b2c6ec7e84aaad17c22a192 to your computer and use it in GitHub Desktop.
案例搜索
$('#scroll-down').on('scroll', function(e){
e.preventDefault();
if($(this).scrollTop() + $(this).innerHeight()>=$(this)[0].scrollHeight){
var id = $('.ajax-show-example').last().data('id');
var category = $('select[name=tag]').val();
var size = $('select[name=entry_size]').val();
var type = $('select[name=entry_type]').val();
$.ajax({
url: '<%= append_example_example_entries_path %>',
type: 'get',
dataType: "script",
data: {
category: category,
size: size,
type: type,
id: id
}
});
}
});
$('#scroll').on('scroll', function(e){
if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight){
$('#load-more').removeClass('hide');
}else {
$('#load-more').addClass('hide');
}
});
$('#load-more').on('click', function(e){
e.preventDefault();
var limit = $('.ajax-show-example').length;
if (limit <= 8){
var id = $('.ajax-show-example').last().data('id');
var category = $('select[name=tag]').val();
var size = $('select[name=entry_size]').val();
var type = $('select[name=entry_type]').val();
$.ajax({
url: '<%= append_example_example_entries_path %>',
type: 'get',
dataType: "script",
data: {
category: category,
size: size,
type: type,
id: id
}
});
}else {
// $('#load-more').notify('无法加载更多', 'warn', { globalPosition: 'top right' })
$.notify("无法加载更多", {
className:'info',
clickToHide: true,
position: 'top rigth'
});
}
});
$(document).on('change', 'select', function(){
$('.show-example').html("");
var tag = $('select[name=tag]').val();
var size = $('select[name=entry_size]').val();
var type = $('select[name=entry_type]').val();
var lang = $('#resume-language').attr('data-language');
$.ajax({
url: '<%= append_example_example_entries_path %>',
type: 'get',
dataType: "script",
data: {
lang: lang,
tag: tag,
size: size,
type: type
},
success: function(){
},
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment