1. Go to this page and download the library: Download robsonsuzin/smodal library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
Botão que vai receber o click
$modal_delete = (new Smodal())
->setSmodaltype("delete")
->setSadddata("js-confirm", "post", url("/" . CONF_VIEW_APP . "/registration/departament"))
->setSaddhtml(
"js-title",
"<b>Atenção:</b> Tem certeza que deseja excluir esse departamento! Essa Ação não pode ser desfeita!"
);
Objeto para ser enviado ao callback
$smodal = (new Smodal('suzin_smodal_departament_address'))
->setSmodalwidth(700)
->setSmodaleffect("bounce")
->setSmodalhtml(
$this->view->render("widgets/registration/views/modal_vehicle", [
"title" => $title,
"vehicle" => $vehicleEdit,
"departaments" => $departaments->order('name')->fetch(true)
]));
$json["smodal"] = $smodal->renderObject();
Monitoramento do callback
if (response.smodal) {
$(this).smodal(response.smodal, template);
}
// Envio Ajax pelo click no data-post
$(document).on("click", "[data-post]", function (e) {
e.preventDefault();
var clicked = $(this);
var data = clicked.data();
var load = $(".ajax_load");
$.ajax({
url: data.post,
type: "POST",
data: data,
dataType: "json",
beforeSend: function () {
load.fadeIn(200).css("display", "flex");
},
success: function (response) {
if (response.smodal) {
$('.suzin_smodal').fadeOut();
$(document).smodal(response.smodal, template);
}
},
error: function () {
ajaxMessage(ajaxResponseRequestError, 5);
load.fadeOut();
}
});
});