mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 11:23:48 -05:00
This commit adds some Javascript that makes AJAX requests as the users changes the content of their template. It then takes the content returned by the backend and inserts it in the page.
42 lines
752 B
JavaScript
42 lines
752 B
JavaScript
(function(window) {
|
|
"use strict";
|
|
|
|
window.GOVUK.Modules.UpdateStatus = function() {
|
|
|
|
let getRenderer = $component => response => $component.html(
|
|
response.html
|
|
);
|
|
|
|
this.start = component => {
|
|
|
|
let id = 'update-status';
|
|
|
|
this.$component = $(component);
|
|
this.$textbox = $('#' + this.$component.data('target'));
|
|
|
|
this.$textbox
|
|
.on('input', this.update)
|
|
.trigger('input');
|
|
|
|
};
|
|
|
|
this.update = () => {
|
|
|
|
$.ajax(
|
|
this.$component.data('updates-url'),
|
|
{
|
|
'method': 'post',
|
|
'data': this.$textbox.parents('form').serialize()
|
|
}
|
|
).done(
|
|
getRenderer(this.$component)
|
|
).fail(
|
|
() => {}
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})(window);
|