$('#modal').modal('show')
.change($('#modalContent').html('<div style="display:flex;justify-content: center;margin: 60px 0;"><img src="/images/loader/35.gif"></div>'))
.find('#modalContent')
.load($(this).attr('href'))
$('#modal').on('show.bs.modal', function(e) {
$('#modalContent').html('<div style="display:flex;justify-content: center;margin: 60px 0;"><img src="/images/loader/35.gif"></div>');
})
class FileUpload {
public input: any = document.getElementById('upload-input');
....
handleFileSelect(event) {
const files = event.target.files;
for(let i = 0; i < files.length; i++) {
const file = files[i];
let type = file.type;
Store.files.push(file);
const fileType: FileType = FileUpload.determineFileType(type);
let count: number = Store.files.length - 1;
if(fileType.type === 'image') {
const reader = new FileReader();
reader.onload = (e: any) => {
let div: any = document.createElement('div');
div.setAttribute('class', 'preview-file');
div.innerHTML = [`<i class="material-icons remove-file" id="${count}">close</i>
<img class="preview" title="${file.name}" src="${e.target.result}" width="100px" height="100px"/>
<div>${file.name}</div>`].join('');
document.getElementById('preview-content').insertBefore(div, null);
FileUpload.removeFile(count);
};
reader.readAsDataURL(files[i]);
} else {
let div = document.createElement('div');
div.setAttribute('class', 'preview-file');
div.innerHTML = [`<i class="material-icons remove-file" id="${count}">close</i>
<img class="preview" title="${file.name}" src="${fileType.icon}" width="100px"/>
<div>${file.name}</div>`].join('');
document.getElementById('preview-content').insertBefore(div, null);
FileUpload.removeFile(count);
}
}
}
static removeFile(count): void {
const removeButton: any = document.getElementById(`${count}`);
removeButton.onclick = () => {
console.log("hello");
}
}
}
new FileUpload();
$(#id).modal('show').find('$idModal').load('#href')
;$('#button').click(functuion(){
$(this).attr(href);// Или примерно так если укажешь data-href $(this).data("href")
})
$('#select-branch').change(function () {
let value = $(this).val();
console.log(value);
if ($(this).val() !== null){
$.ajax({
type: 'get',
url: `${window.location.origin}/branch/rooms/${value}`,
beforeSend: function () {
$('.select-room').css('display', 'block').html(`<option value="" disabled selected>Загрузка</option>`)
}
})
.done(res => {
console.log(res);
let room = res.map(room => {
return `<option value="${room.id}">${room.name}</option>`
});
$('.select-room').css('display', 'block').html(`<option value="" disabled selected>Выберите комнату</option>${room}`);
})
.fail(err => console.error(err.responseJSON.message));
}
})