A
A
Aleksandr_KH2019-05-17 09:43:23
Vue.js
Aleksandr_KH, 2019-05-17 09:43:23

How to dynamically change content in Material Vue Modal?

There is a list of messages that I output via v-for. Initially, I see a preview of the message, i.e. not the full text, but to see the full text I have to click on the corresponding message, a modal pops up with all the details.
The crux of the question is how to display the relevant content in the modal window?

Message output:

<div v-for="message in messagesList"
                     :key="message.msgFrom"
                     :class="`message-row d-flex ${message.msgNew}`"
                     @click="showMessageModal = true">
                    <div class="message-date">
                        <span class="day">{{ message.day }}</span>
                        <span class="month">{{ message.month }}</span>
                    </div>
                    <div class="message-content">
                        <span class="message-from">Message from {{ message.msgFrom }}</span>
                        <p class="message-txt">{{ message.msgText }}</p>
                    </div>
                </div>

Modal window:

<md-dialog :md-active.sync="showMessageModal">
            <div class="box-wrapper">
                <div class="box-header">
                    <div class="box-header-left">
                        <span class="box-title">Message from {{ Здесь нужно выводить соответствующее имя }}</span>
                    </div>
                    <div class="box-header-right">
                        <div class="icon-wrap" @click="showMessageModal = false">
                            <Icon name="close" fontSize="23px" color="#fff" />
                        </div>
                    </div>
                </div>
                <div class="box-body">
                    {{ А здесь выводить полное сообщение }}
                </div>
            </div>
        </md-dialog>

Answer the question

In order to leave comments, you need to log in

7 answer(s)
0
0xD34F, 2019-05-17
@Aleksandr_KH

Add a property to the component that will be a link to the message clicked by the user, and update it when the window opens:
@click="openModal(message)"

data: () => ({
  openedMessage: {},
  ...
}),
methods: {
  openModal(message) {
    this.openedMessage = message;
    this.showMessageModal = true;
  },
  ...
},

Well, in the modal window, respectively, display the desired values:
<span class="box-title">{{ openedMessage.какоеТамУВасСвойствоОтвечаетЗаЭтотTitle }}</span>
...
<div class="box-body">{{ openedMessage.нуТутТожеВамВиднееЧтоНаписать }}</div>

R
ReactiveSnaile, 2019-03-16
@ReactiveSnaile

$price = str_replace(array(" ", chr(0xC2).chr(0xA0)), '', $price);

A
Alexander Aksentiev, 2017-05-11
@Sanasol

regex to remove/replace any spaces and hyphens \s+

D
display: block, 2017-05-11
@qork

str_replace([' ','&nbsp;'],'',$price);

A
andrey_o_v, 2017-05-11
@andrey_o_v

it is displayed as &nbsp;but in fact it may have some kind of character code, the string encoding may be different.
For example, here is the article "An interesting nuance with spaces when cleaning texts with the preg_replace function"
https://ph0en1x.net/17-interesnyj-nyuans-s-probela...
he uses a hex editor, I think there are easier solutions) some kind of online detector, character parser, such as display all characters with codes

N
Nikita11111111, 2018-04-18
@Nikita11111111

str_replace(chr(160), ' ', html_entity_decode($arFields['NAME']))

1
1gor007, 2020-11-17
@1gor007

str_replace("\xC2\xA0", "", $price);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question