Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent lengthMenu manipulation through the dom #230

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions js/core/core.length.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@

function _fnLengthChange ( settings, val )
{
var len = parseInt( val, 10 );
settings._iDisplayLength = len;
// val: is coming directily from the dom
var len = parseInt(val, 10),
//Add a way to prevent end user from changing the lengthMenu value in the dom
menu = settings.aLengthMenu,
d2 = Array.isArray(menu[0]),
originalLengths = d2 ? menu[0] : menu;
// if the value is not in the original values when initiating the data table then choose the min value
// this will be of use when using ssp whith large tables where you want to make sure that there is a LIMIT restriction
settings._iDisplayLength = originalLengths.includes(len) ? len : Math.min(...originalLengths);

_fnLengthOverflow( settings );

Expand Down