0

基本的にブートストラップ モーダルなコンポーネントを作成しました。モーダルではselectizeを使いたいです(bootstrap selectも試しました)。問題は、選択に静的な値がある場合は機能しますが、動的データを入力すると失敗することです。Uncaught TypeError: Cannot read property 'appendChild' of null

html は次のとおりです。

<div class="form-group">
    <label for="newContactModalType">Type*</label>
    <select id="newContactModalType" name="type_id">
        <option v-for="type in clientTypes" value="{{ type.id }}">{{ type.name }}</option>
    </select>
</div>

そしてコンポーネント:

  export default {
    vuex: {
      getters: {
        clientTypes: state => state.clientTypes.list
      }
    },

    events: {
      'showNewContactModal': () => {
        $('#newContactModal').modal()
      }
    },

    ready() {
      $('#newContactModalType').selectize()
    }
  }

clientTypes リストを取得するために vuex を使用しています。コンポーネントのデータプロパティでclientTypesを定義すると機能するため、これは何かが間違っていることに気づきました。私もどこに電話すればいいのかわからない.selectize()。私が考えることができる最高のものは、ready() メソッドです。

前もって感謝します!

4

0 に答える 0