E
E
evomed2022-01-21 11:26:04
Vue.js
evomed, 2022-01-21 11:26:04

How to scroll window inside modal up when button is clicked?

I use sweet modal for vue https://sweet-modal-vue.adepto.as/

There are tabs in the modal

<sweet-modal ref="modal">

            <sweet-modal-tab id="comments" title="comments" ref="commentsTab">
                <comments/>
            </sweet-modal-tab>

// длинный текст

// кнопка открывающая таб комментариев
<a href="" class="btn" @click.prevent="openComments">Comments</a>

        </sweet-modal>


method that opens the comments tab
openComments() {
            this.$refs.commentsTab.active = true
        },


Comments open. Everything is fine. But since the text is large, then the comments are opened not from the beginning, but from the end. The modal window was already scrolled when the button was clicked. How to scroll the modal to the top at the moment of clicking on the button for opening comment tabs?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2022-01-21
@evomed

1. Don't use this shit, it's made by someone who doesn't understand how to work in vue.
2. Something like that (did not check):

this.$refs.commentsTab.active = true;
this.$nextTick(() => this.$refs.commentsTab.$el.scrollIntoView());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question