実現したいこと
Backboneで各種ライブラリを使用したい。
まずはDatatablesを使用したいと考えています。(https://datatables.net/)
試したこと
npmでdatatables.net関連のモジュールを導入して、
既に動いているコードにライブラリ部分を追加で記述しました。
HTML
1・・・ 2<table id="dataTable"> 3 ・・・・ 4</table> 5・・・
JavaScript
1・・・ 2require('datatables.net-bs')(); 3require('datatables.net-buttons-bs')(); 4require('datatables.net-buttons/js/buttons.flash.js')(); 5require('datatables.net-responsive-bs')(); 6 7const hoge = Backbone.View.extend({ 8 ・・・ 9 initialize(){ 10 this.render(); 11 } 12 13 render(){ 14 this.$el.empty(); 15 16 this.$el.html(this.template({ 17 ・・・ 18 })); 19 20 $('#dataTable')[0].DataTable(); 21 22 return this; 23}) 24・・・
実行結果(エラー結果)
Chrome DevToolで確認しました。
Uncaught TypeError: $(...)[0].DataTable is not a function
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。