0

I want close modal after save data

$this->dispatchBrowserEvent('closeModel');

<script>
    window.addEventListener('closeModel', event => {
        $("#Add_Student_Model").modal('hide');
    })
</script>

But error:

Uncaught Reference Error: $ is not defined

1
  • 1
    Are you using jQuery by any chance? If so it is likely because your function is being defined before jQuery has loaded. Commented May 29, 2021 at 11:20

1 Answer 1

0

You should type your code inside function block.

<script>
    (function($) {
        $this->dispatchBrowserEvent('closeModel');

        window.addEventListener('closeModel', event => {
            $("#Add_Student_Model").modal('hide');
        })
    })(jQuery)
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.