0

I'm trying to get the value of a drop down list and change the div content using a get request view

 <div class="row row-mb2" id="Produit-tab">
 @Html.DropDownList("Version", new SelectList(ViewBag.Versions, "IdVersion", "VersionProduit"), new { @id = "version" })
 </div>

<div id="versiondetails"></div>

script :

 $.Produit.settingsView = new Vue({
            el: '#Produit-tab',
            data:
                {
                version:''
                },
            watch: {
                version: function (versionprod) {
                    $.get("@Url.Action("Details", "VersionProduit", new {id = "_PARAM_" })".replace("_PARAM_", versionprod), function (data) {

                        $('#VersionDetails').html(data);
                    });
                }
            }//,.....rest of the code 

I'm usually using vue.js with input using v-model="..." but with razor i can't inject a vue.js attribut i tried this but it razor doesn't accept it

 @Html.DropDownList("Version", new SelectList(ViewBag.Versions, "IdVersion", "VersionProduit"), new { @id = "version" ,@v-Model="version" })

1 Answers1

1

use @v_model insted of @v-Model it will solve your problem.

@Html.DropDownList("Version", new SelectList(ViewBag.Versions, "IdVersion", "VersionProduit"), new { @id = "version" ,@v_model="version" })
Sagar Shinde
  • 150
  • 10
  • please make use of the `code formatting` provided by SO. Select your code and press Ctrl + K to highlight it as such – Neuron Nov 06 '17 at 09:01