2016-07-20 8 views
1

私はjqueryの-UIのDatePickerの要素をインポートする/使用するためにこのサイトを参照しようとしている: http://ilikekillnerds.com/2016/02/using-jquery-ui-widgets-in-aurelia/jQuery UIでdatepickerをインポートできないのはなぜですか?

私の最初の障害は、私のクラスにインポートしようとしています。私は普通の

import 'jquery'; 
import 'jquery-ui'; 

を行う場合には、罰金、それをインポートして、私は「日付ピッカー」オブジェクトを参照することはできません。私は、ウェブサイトのようにそれをインポートする場合は、あまりにも私に語った:

import 'jquery'; 
import { datepicker } from 'jquery-ui'; 

私はそれがモジュールを見つけることができない方法についての第二import文でエラーが発生します。私が最初に言ったように、もし私がちょうどimport 'jquery-ui'、私のコードの下に私のコードの下で認識しない$(this).datepicker();

私はちょうどこのアプリケーションを実行すると、私は通常の入力ボックスを取得しないdatepickerこれは私が ' bluebird.min.jsから取得メートル:

未処理の拒絶はTypeError:jquery_1.defaultは関数ではありません

このライブラリをインポートし、それを使用する権利方法は何ですか?

フルカスタム要素コード

import { customElement, bindable, inject } from 'aurelia-framework'; 
import $ from 'jquery'; 
import 'jquery-ui'; 

@customElement('date-picker') 
@inject(Element) 
export class DatePicker { 
    @bindable id = ''; 
    @bindable name = ''; 
    @bindable options = {}; 
constructor(Element) { 
    this.element = Element; 

    if (!this.id && this.name) { 
     this.id = this.name; 
    } 

    if (!this.name && this.id) { 
     this.name = this.id; 
    } 
} 

attached() { 
    $(`#${this.id}`).datepicker(this.options) 
     .on('change', e => { 
      let changeEvent = new CustomEvent('input', { 
       detail: { 
        value: e.val 
       }, 
       bubbles: true 
      }); 

      this.element.dispatchEvent(changeEvent); 
     }); 
} 

detached() { 
    $(`#${this.id}`).datepicker('destroy').off('change'); 

} 
} 

HTMLパート

<template> 
    <input type="text" id.bind="id" name.bind="name"> 
</template> 
+0

どのモジュールローダーを使用していますか? systemjsまたはwebpack? –

+0

@FabioLuz systemJS – James

+0

$(this).datepicker()の問題について... config.jsファイルに2つのjQueryバージョンがあるかどうかを確認してください。私は絶えずこれと戦っている。通常、github - jqueryのjQueryバージョン: "github:components/[email protected]"がBootstrapの依存関係としてインストールされています。 jquery UIのような他のライブラリをインストールすることで、npmから別のバージョンを入手することもできます。 config.jsのjquery-ui libの依存関係を確認してください。 –

答えて

0

は、最後にそれが動作するようになりました。私はtypescriptファイルにインポートする場合は、次のようにそれが動作するなど、種類/パッケージをアンインストール/インストールの時間後:

import 'jquery'; 
import 'jquery-ui'; 

私はそれは私が費やしてきたすべての時間の後にそれは簡単だと信じてすることはできません。..

関連する問題