P
P
part_os2021-03-02 21:21:46
Vue.js
part_os, 2021-03-02 21:21:46

Why do click and other events fire 2 times inside vuejs id=app tag?

hello, I started translating the site to vujs, there is a button

<button type="button"
id="js-add-city"
data-action ="{{ route('addCity', ['account' => Route::input('account'), 'region' => $region['id']]) }}"
>
 <span class="glyphicon glyphicon-plus"></span>
 Добавить город
 </button>

and there is a click handler
$(document).ready(function() {
    $(document.body).on('click', '#js-add-city', function () {

        var $button = $(this);
.....

    });
});


for some unknown reason, this event is called, and others 2 times each, exactly when I wrap it in vuejs in the base blade template
<div id="app">
@yield('content')
</div>


if I do it inside the template, then everything works as it should
@extends('layouts.base')

@section('content')
    <div id="app">
.....
    </div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
part_os, 2021-03-02
@part_os

inside the template, a file with js was connected,
if it was placed inside the vue root tag, then a double call occurs, the file was connected to the stack
@push('scripts')
@endpush

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question