From this great answer I have a working jQuery implementation of a simple call to an existing view using AJAX. Which is brilliant, but I want to specify the number of results differently to as is setup in the existing view, and I want to know what other options I can use under view_args
.
I can't find documentation/a full example of what's available and how to use it. Is there any?
$.ajax({
url: url,
type: 'post',
data: {
view_display_id: v_display,
view_name: v_name,
// view_args: {}, // your views arguments
view_args: v_args,
},
dataType: 'json',
success: function (response) {
if (response[1] !== undefined) {
return response[1].data; // do something with the view
}
}
});
I inspected the HTML of the Views admin page and saw the pager was encapsulated from the other arguments, and tried this but it carried on supplying 6 items (which is odd because the view is saved to display 10):
var data = {
'view_name':'ajax_test',
'view_display_id':'block',
'pager_options': {
'items_per_page':'1',
}
};
$.ajax({
url: '/views/ajax',
type: 'post',
data: data,
//pager_options: {items_per_page:1},
dataType: 'json',
success: function (response) {
if (response[1] !== undefined) {
document.write(response[1].data); // do something with the view
}
}
});