Mark Tabor

Mark Tabor

  • 586
  • 2k
  • 464.3k

can we call sweet alert in partial view

Aug 10 2024 7:12 AM

I have partial view which I am calling in main view here is the code 


<form method="post" id="parti" name="parti">
    <button type="button" class="btn btn-danger" onclick="clickme()">Delete</button>
</form>
@section scripts {
    <script type="text/javascript">
        function clickme(info) {
            Swal.fire({
                title: 'Confirmation',
                text: 'Are you sure you want to save this information?',
                icon: 'question',
                showCancelButton: true,
                confirmButtonText: 'Ok',
                cancelButtonText: 'Cancel'
            }).then((result) => {
                if (result.isConfirmed) {
                    // Perform the action if the user confirms
                    $("#optype").val(info);
                    $("#parti").trigger('submit');
                }
            });
        }

        // Ensure jQuery is ready
        $(document).ready(function () {
            // Additional document ready logic if needed
        });


    </script>
}

but on button click I see the console it says clickme is not defined even though its there.remember its in partial veiw 


Answers (2)