// Auto update layout if (window.layoutHelpers) { window.layoutHelpers.setAutoUpdate(true); } $(function() { // Initialize sidenav $('#layout-sidenav').each(function() { new SideNav(this, { orientation: $(this).hasClass('sidenav-horizontal') ? 'horizontal' : 'vertical' }); }); // Initialize sidenav togglers $('body').on('click', '.layout-sidenav-toggle', function(e) { e.preventDefault(); window.layoutHelpers.toggleCollapsed(); }); }); $(function () { // Modal handler var placeholderElement = $('#modal-placeholder'); // Loading modal $('button[data-toggle="ajax-modal"]').click(function (event) { var url = $(this).data('url'); $.get(url).done(function (data) { placeholderElement.html(data); placeholderElement.find('.modal').modal('show'); }); }); // Modal submit placeholderElement.on('click', '[data-save="modal"]', function (event) { event.preventDefault(); var form = $(this).parents('.modal').find('form'); var actionUrl = form.attr('action'); var dataToSend = form.serialize(); $.post(actionUrl, dataToSend).done(function (data) { var newBody = $('.modal-body', data); placeholderElement.find('.modal-body').replaceWith(newBody); // If valid hide modal window var isValid = newBody.find('[name="IsValid"]').val() == 'True'; if (isValid) { placeholderElement.find('.modal').modal('hide'); } }); }); });