HTMLGuyLLC/jConfirm

modal is not displayed

Closed this issue · 1 comments

try to install jconfirm in my laravel app

script in views

<script type="text/javascript" src="{{asset('/js/jConfirm.js')}}"></script>
<script  type="text/javascript">
    jQuery(document).ready(function() {
        $.jConfirm.defaults.question = '{{ __("¿Estás seguro?") }}';
        $.jConfirm.defaults.confirm_text = '{{ __("Sí") }}';
        $.jConfirm.defaults.deny_text = '{{ __("No") }}';
        $.jConfirm.defaults.position = 'top';
        $.jConfirm.defaults.theme = 'black';
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
    });
</script>
<script  type="text/javascript" src="{{asset('js/functions.js')}}"></script>

my file functions.js
jQuery(document).ready(function () { $('.delete-record').jConfirm().on('confirm', function(e){ const btn = $(this); const route = btn.data("route"); jQuery.ajax({ method: "DELETE", url: route, success: function (data) { window.location.reload(); }, error: function (error) { window.location.reload(); } }) }); });

Error en web console
Uncaught TypeError: Cannot read property 'defaults' of undefined
at HTMLDocument. (units:340)

Uncaught TypeError: $(...).jConfirm is not a function
at HTMLDocument. (functions.js:2)

for jconfirm to work in laravel

in js folder of resources js in app.js file add next code

window.jConfirm = require('jconfirm');