1
                            <section class="scans">
                                  <h3>Scans</h3>

                                  <ul v-if="scans.length === 0">
                                    <li class="empty">No scans yet</li>
                                  </ul>

                                  <transition-group name="scans" tag="ul">

                                            <li v-for="scan in scans" :key="scan.date" :title="scan.content">

                                            {{ scan.content }}

                                            </li>
                                  </transition-group>

                             </section>

How can i pass '{{ scan.content }}' to a html element (textbox) or php ($scanned) variable?

3
  • 1
    Are you asking how to display scan.content in a textbox? Or do you want to know how to POST your client-side data to the server so PHP can have access to it? Commented Oct 21, 2017 at 14:43
  • I want to know how to post that client-side data to my server side so i can access it via php Commented Oct 21, 2017 at 14:45
  • I suggest you look into an AJAX POST of some type (example: vue-resource or axios). Commented Oct 21, 2017 at 14:51

2 Answers 2

2

Depending on how you want your data to be sent either make a form with hidden elements (usually if the user should initiate the post request) or make an AJAX POST directly in Javascript. (if it should be 'seamless'/in the background)

Sign up to request clarification or add additional context in comments.

1 Comment

Thankyou for your answer, i'll give it a try and keep you posted
-1

Figure out how to make Vue send AJAX, maybe following a recent tutorial, like: https://vuejsdevelopers.com/2017/08/28/vue-js-ajax-recipes/ since apparently simply giving an id to the transition-group and using innerHTML and document.getElementById to fetch the data is for some reason bad form and should be avoided, for some reason...

2 Comments

Since the data is already in his Vue data, there's no need to use innerHTML and DOM lookups to find it. Vue makes a clear separation between data and presentation which removes the needs to DOM manipulation/querting.
Patric, I edited the answer, thanks for your suggestion, may I know how exactly does one send data to Vue? I'm a Vue newbie myself!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.