1

I have this

<f7-list form>
<!-- Textarea -->
  <f7-list-item>
   <f7-input type="textarea" placeholder="Default address" id="address"></f7-input>
  </f7-list-item>
</f7-list>
<!-- Button Nex -->
<f7-block>
  <f7-button class="" value="1" id="btnPageAdress" href="/step1/">Next</f7-button>
</f7-block>

<script>
    export default {
      }
    }
</script>

And I need to send data (address) from textarea to server on button click (#btnPageAdress). (I just started to learn Vue, and tried to google it, but or something that does not fit or complex options) Can someone help me?

I found [https://jsfiddle.net/sh70oe4n/]

and i do this

<f7-block id="addressBox">
  <f7-list form id="address-form">
    <!-- Textarea -->
  <f7-list-item>
  <f7-input type="textarea" placeholder="Default address" id="address"  ref="addressArea"></f7-input>
  </f7-list-item>
  </f7-list>
  <!-- Button Nex -->
  <f7-block>
  <f7-button class="" value="1" id="btnPageAdress" href="#" @click.prevent="getFormValues()">Next</f7-button>
  </f7-block>
  </f7-block>

In Vue.js

  // My Vue JS
  new Vue({
    el: '#addressBox',
      data: {
            address: ''
        },
      methods: {
        getFormValues () {
          this.address = this.addressArea.value,
          console.log(this.address)
        }
      }

  })

But still does not work

1
  • You need an http library to send https requests to a server. For that you must use http or better one axios Commented Nov 28, 2017 at 15:10

1 Answer 1

4
<div id="address-form">
  <textarea v-model="address"></textarea>
  <button v-on:click="sendAddress()">Send</button>
</div>

<script>
  export default {
    el: '#address-form',
    data() {
      return {
        address: ''
      }
    },
    methods: {
      sendAddress: function () {
        var addressToSend = this.address
        //http request to server here
      }
    }
  }
</script>

Documentation for VueJS event handling: https://v2.vuejs.org/v2/guide/events.html

Note: I haven't tested the code so there could be some errors.

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

Comments

Your Answer

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