我正在使用Jquery List.js库。由于list.js库没有动态更改页面上记录数量的选项,所以我尝试通过change函数动态更新页面值。问题是,值的传递是正确的,并且它显示在控制台中,但是列表没有在后端更新。我尝试过的代码是
var x = $(function()
{
//rows are the id of drop down selection
$('#rows').change(function(){
console.log($(this).val());
$(this).val();
});
});
//default value is set if nothing selected
if(!$.isEmptyObject( x ))
x=10;
var options = {
valueNames: [ 'territory', 'territory_id'],
page: x,
plugins: [
ListPagination({}
)]
};
var contactList = new List('my-cool-sortable-table-wrapper', options);
contactList.sort('territory', { order: 'asc' });任何帮助都将不胜感激。谢谢
发布于 2016-10-25 07:29:10
您缺少更新列表,这就是您看不到更改的原因。文档指出,您需要在更改后更新对象object.update()。
请参见下面的代码:
var x = 10
$('#rows').change(function() {
x = $(this).val();
updateList(x);
})
var options = {
valueNames: ['territory', 'territory_id'],
page: x,
plugins: [
ListPagination({})
]
};
var contactList = new List('my-cool-sortable-table-wrapper', options);
contactList.sort('territory', { order: 'asc' });
function updateList(x) {
contactList.page = x;
contactList.update()
}https://stackoverflow.com/questions/40232290
复制相似问题