P
P
PetrTar2019-04-10 18:20:05
JavaScript
PetrTar, 2019-04-10 18:20:05

Why does @click fire once?

in the component's template the following code:

<td :style="{background: colorCell[k]}" :class="getClass(k)" v-for="(typeFlat,k) in build" :key="k" @contextmenu.prevent="addString($event, building[j].id, k)" @click="changeCell(build[k], k, build.id)">
                    <span v-if="isLink(typeFlat)">
                        <a  href="javascript:void(0)">
                            {{ typeFlat.substr(0, lengthString) }}
                        </a>
                    </span>
                    <span v-else>
                        {{ typeof typeFlat === 'string' ? typeFlat.substr(0, lengthString) : typeFlat}}
                    </span>
                <div style="display: none" :ref="build.id+k">
                    <textarea :value="message" @change="message = $event.target.value" @blur="finishСhange(j)"/>
                    <select @blur="finishСhange()" @click="setMessage($event)" v-model="message">
                    </select>
                </div>
            </td>

the @click event fires a method that changes the this.eventFlag flag:
changeCell(val, title, id){
console.log(this.eventFlag)
if (this.eventFlag){
                this.eventFlag = false
            } else {
                this.eventFlag = true
            }
}

When a cell is clicked, the eventFlag should toggle, but it either fires or doesn't fire. Patterns of "non-operation" could not be identified"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Drozdov, 2019-04-10
@bagzon

Go from the opposite, remove all unnecessary, all attributes, menus, etc., and check. Might be in conflict with something.

P
PetrTar, 2019-04-11
@PetrTar

The changeCell method made the div with ref=build.id+k visible, and the element nested in it in focus, by clicking on another td, the focus disappeared and made the div with ref=build.id+k - disaplay: none, after that the @ event click on cells didn't work. When I moved the hide div from ref=build.id+k to the changeCell method, everything worked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question