개발 무지렁이

[Spring Boot] toastr을 이용해서 성공메세지 보여주기 본문

Backend/스프링부트

[Spring Boot] toastr을 이용해서 성공메세지 보여주기

Gaejirang-e 2022. 12. 30. 14:24

toastr


https://codeseven.github.io/toastr/demo.html

[resources/static/resource/common/commons.js]

toastr.options = {
    closeButton: false,
    debug: false,
    newestOnTop: false,
    progressBar: false,
    positionClass: "toast-top-right",
    preventDuplicates: false,
    onclick: null,
    showDuration: "300",
    hideDuration: "1000",
    timeOut: "5000",
    extendedTimeOut: "1000",
    showEasing: "swing",
    hideEasing: "linear",
    showMethod: "fadeIn",
    hideMethod: "fadeOut"
};

function successModal(msg) {
    toastr["success"](msg);
}

[layout.html]

<body>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
   ...
   ...
   ...
  <script src="/resource/common/common.js"></script>

  <script th:inline="javascript">
    const params = /*[[ ${param} ]]*/ null;

    if (params.msg) {
        successModal(params.msg);
    }
  </script>
</body>
Comments