Skip to content

Instantly share code, notes, and snippets.

@yellow1912
Last active September 23, 2019 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yellow1912/4cd0f04b6e9a5f5f3dab3204171bdc79 to your computer and use it in GitHub Desktop.
Save yellow1912/4cd0f04b6e9a5f5f3dab3204171bdc79 to your computer and use it in GitHub Desktop.
sample js code
(function (nu) {
nu.ready(function () {
var elements = nu.querySelectorAll('.nl-widget-sleek-form-contact');
for (var i=0; i < elements.length; i++) {
var form = nu.querySelector('form', elements[i]);
nu.addEventListener(form, 'submit', function (e) { console.log('a');
nu.querySelector('button', e.target).setAttribute('disabled', 'disabled');
});
let eventSrv = ni.provider.get('service').get('event');
let events = ni.provider.get('const').get('plugin.form.events');
let submitDone = events.SUBMIT_DONE.replace('%s', form.getAttribute('data-form-id'));
// when the form is submit, we should update the form
eventSrv.on(submitDone, submitDone, function (e) { console.log('b');
nu.querySelector('button', e.form).removeAttribute('disabled');
});
}
});
})(nu)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment