Home>

The person who asked the question "jQuery prop does not work properly."
It doesn't seem to be a jQuery-only issue, so I'll ask a new question.

I installed laravel/ui referring to the following site.
https://qiita.com/n_oshiumi/items/cf00a3f7def92a472a09

I installed it, but it didn't work by itself, and jQuery worked by writing the following to the blade.

<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

I was able to confirm the ajax communication by referring to the following site.
https://hdtuto.com/article/ajax-post-request-in-laravel-6-example

However, it is malfunctioning with a simple button operation.

jQuery (function ($) {
    $('#buttonA'). click (function () {
        $('#buttonB'). hide ();
    });
});

When you click button A, button B should disappear, but it disappears for a moment and then returns immediately.
It is an image that the screen is reloaded immediately after jQuery works and it returns to the original.

Asked before

jQuery (function ($) {
    $('# search_button'). click (function () {
        $('# send_button'). prop ('disabled', false);
    });
});


Does exactly the same.

I thought it was a problem with jQuery alone, but
・ Laravel/ui has been installed
・ Relationship with Laravel's blade
I wonder if it is related to such things, so I will ask the question again.

  • Answer # 1

    I make a mistake because I believe in a strange blog. All you need to do to learn Laravel is never look at weird blogs.

    All you need is knowledge of the modern front of node.js/npm. Laravel is based on the premise that everyone knows this much, so you can't use it without knowing it.

    If you have ui: 1.x installed on Laravel 6
    resources/js/bootstrap.jsI see.
    You don't have to load it yourself with


    bootstrap.js is loaded from app.js.
    How to use this is to build and use it with laravel-mix (webpack).
    https://readouble.com/laravel/6.x/ja/mix.html
    Since the built file is made public, read this with view.
    If you made it with ui, this is also prepared from the beginning, so you do not have to change it yourself.
    As much as mix ().

    This is the story of the front desk, which has nothing to do with Laravel.
    It requires a lot of learning from the basics because it does everything that should not be done, such as reading jquery with script or writing JS directly in view.