Skip to content
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
16 changes: 13 additions & 3 deletions dev/jquery.jtable.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
//Options
actions: {},
fields: {},
security: { antiforgerytoken: null},
animationsEnabled: true,
defaultDateFormat: 'yy-mm-dd',
defaultChangeMonth: false,
Expand Down Expand Up @@ -113,7 +114,8 @@
this._normalizeFieldsOptions();
this._initializeFields();
this._createFieldAndColumnList();

this._addAntiforgeryToken();

//Creating DOM elements
this._createMainContainer();
this._createTableTitle();
Expand All @@ -123,9 +125,17 @@
this._createErrorDialogDiv();
this._addNoDataRow();

this._cookieKeyPrefix = this._generateCookieKeyPrefix();
this._cookieKeyPrefix = this._generateCookieKeyPrefix();
},
/* Adds antiforgery token for MVC razor pages. to prevent cross-site request forgery by adding token to ajax call header
*************************************************************************/
_addAntiforgeryToken: function () {
var self = this;
if (self.options.security.antiforgerytoken !== null ) {
var headerobj = JSON.parse('{ "RequestVerificationToken":"' + self.options.security.antiforgerytoken + '" }');
self.options.ajaxSettings.headers = headerobj;
}
},

/* Normalizes some options for all fields (sets default values).
*************************************************************************/
_normalizeFieldsOptions: function () {
Expand Down