2017-06-05 15 views
0

私はVUE-ストラップから先行入力コンポーネントを使用しています、私は私の入力テキストにデータをスタンプします選択にヒットした後にコールバックをしようとしてVueJS 2先行入力のコールバックメソッド

アム。

私が入力を押すと、inventoryNameとinventoryIdは正常にスタンプされますが、inventoryCodeコンポーネントはリセットされます。

リセットしないようにするにはどうしたらいいですか?私がconsole.logから見ることができるように、それは価値があります。

<typeahead v-model="inventoryCode" placeholder="Inventory code..." async="{{url('api/inventory')}}/" :template="inventorySearch" :on-hit="inventoryCallBack"></typeahead> 
<input type="text" name="inventory_name" id="inventory_name" class="form-control" v-model="inventoryName" readonly /> 

new Vue({ 
     el: '#app', 
     components:{Typeahead}, 
     data: { 
      'inventoryCode': '', 
      'inventoryName': '', 
      'inventoryId': '', 
      'inventorySearch': '<div style="min-width:150px;"><b>@{{item.inventory_name}}</b></div><div>@{{item.inventory_code}}</div><div>@{{item.inventory_short_desc}}</div>' 
     }, 
methods:{ 
    inventoryCallBack: function(item){ 
        console.log(item.inventory_code); 
        this.inventoryCode = item.inventory_code; 
        this.inventoryName = item.inventory_name; 
        this.inventoryId = item.id; 
        console.log(this.inventoryCode); 
       }, 
} 
}); 
+0

第1に、 'inventoryCallBack'関数はメソッドのプロパティでなければなりません。 –

+0

@SrinivasDamam申し訳ありませんが、タイプミス、それはメソッドの小道具です。他のモデルには値が割り当てられていますが、inventoryCodeは割り当てられていません。 –

+0

あなたは 'components:{Typeahead}'に大文字の「T」があります。それは小文字ではいけませんか? – redshift

答えて

0
inventoryCallBack: function(item){ 
        console.log(item.inventory_code); 
        this.inventoryCode = item.inventory_code; 
        this.inventoryName = item.inventory_name; 
        this.inventoryId = item.id; 
        return item.inventory_code 
       }, 

これはトリックを行う必要があり、この部分を逃しました。

関連する問題