For example, when I (administrator) create a record and leave the Bootstrap toggle on, the record will be visible to the users. However, if I create a record and make the Bootstrap toggle off the record will be invisible to the users.
<script>
//Using a function technique to create a JavaScript class, WebFormData
function WebFormData(inSessionSynopsisName, inIsVisible) {
this.sessionSynopsisName = inSessionSynopsisName;
this.isVisible = inIsVisible;
}
$('#toggle-event').change(function () {
var collectedIsVisible = $('#isVisibleInput').val();
})
$('#saveButton').on('click', function () {
var collectedSessionSynopsisName = $('#sessionSynopsisNameInput').val();
var webFormData = new WebFormData(collectedSessionSynopsisName, collectedIsVisible);
var webFormDataInString = JSON.stringify(webFormData);
$saveSessionSynopsisHandler = jQuery.ajax({
type: 'POST',
url: '/API/SessionSynopses/',
dataType: 'json',
contentType: 'application/json;',
data: "'" + webFormDataInString + "'"
})//end of ajax() call
$saveSessionSynopsisHandler.done(function (data, textStatus, jqXHR) {
new Noty({
text: data.message, type: 'success',
layout: 'center',
template: '<div class="noty_message"><span class="noty_text"></span>'
}).show();
});//end of saveCourseHandler.done();
$saveSessionSynopsisHandler.fail(function (data, textStatus, jqXHR) {
console.log(textStatus);
console.log(data);
console.log(jqXHR);
new Noty({
text: data.responseJSON.message, type: 'error',
layout: 'center',
template: '<div class="noty_message"><span class="noty_text"></span>'
}).show();
});//end of $saveCourseHandler.fail();
});//end of $('#saveButton').on('click', function () {
</script>
在用户加载页面之前检查:如果用户admin更改了按钮的样式以将其打开,否则,如果用户不是admin更改了按钮的样式以将其关闭以在加载页面之前进行一些处理,则可以使用onunload,请阅读此https ://www.w3schools.com/jsref/event_onunload.asp
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.