-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
Copy pathcommon.js
34 lines (30 loc) · 1018 Bytes
/
common.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'domReady!'
], function ($) {
'use strict';
/* Form with auto submit feature */
$('form[data-auto-submit="true"]').submit();
//Add form keys.
$(document).on(
'submit',
'form',
function (e) {
var formKeyElement,
form = $(e.target),
formKey = $('input[name="form_key"]').val();
if (formKey && !form.find('input[name="form_key"]').length && form[0].method !== 'get') {
formKeyElement = document.createElement('input');
formKeyElement.setAttribute('type', 'hidden');
formKeyElement.setAttribute('name', 'form_key');
formKeyElement.setAttribute('value', formKey);
formKeyElement.setAttribute('auto-added-form-key', '1');
form.get(0).appendChild(formKeyElement);
}
}
);
});