デルフィン:
私は、テーブルと持っている多くのそれらの内部入力で細胞を
私は、イベントがトリガさからkeyup、keydownイベントの値を取得し、任意の変更は、入力ボックスに行われたとき入ることにしたいです。
私が試してみました物事は私のjsの中で次のものが含ま
var sources = document.querySelectorAll('td');
var source = Rx.Observable.fromEvent(sources, 'click');
Rx.Observable.fromEvent(sources,'click')
.map(v => {return v})
.subscribe(
v => { console.log(v) },
e => { console.log(e) },
() => { console.log('complete') }
);
私はRxJsの初めてのユーザーだと、最初のセルだけがテーブルの他の細胞にイベントをトリガし、できない理由を理解しません。どのように私はすべてのセルを超えるイベントを達成することができますか?
kctang:
このような何かを試してみてください:
// get the sources into an array
const sources = document.querySelectorAll('td')
const sourcesArray = []
sources.forEach(source => sourcesArray.push(source))
// any even from the merged observables will emit a value...
merge(
// for each source, create an observable via fromEvent
...sourcesArray.map(source => fromEvent(source, 'click'))
).pipe(
// ...value emitted can be from any of the merged observables (i.e. the fromEvent())
// note: pipe() and tap() is optional...
tap(val => console.log(`pipe an chain whatever you need here`))
).subscribe(val => console.log(`use next if u just need the next value... ${val}`))
FYI、私はコードを実行しませんでしたが、考え方は正しいはずです。お役に立てれば。