下記のコードによって、サブテールに追加された行の特定のフィールドの背景色を変更しています。ブラウザ版は想定通りの動きとなりましたが、mobile版ではうまくいきません。
(() => {
"use strict";
kintone.events.on("mobile.app.record.edit.change.コピー",(event) => {
const table = document.querySelector('.subtable-XXXXXXX',);
const observer = new MutationObserver((mutationList) => {
for (const mutation of mutationList) {
if (mutation.type === "childList") {
// 読み込まれた行のtr要素を取得
// 配列にしているが、基本は一つずつ呼び出される
const trs = Array.from(mutation.addedNodes);
trs.forEach((tr) => {
// ex) 12~24列目のセルの背景色をオレンジにする
tr.cells[12].style.backgroundColor = 'orange';
tr.cells[13].style.backgroundColor = 'orange';
tr.cells[14].style.backgroundColor = 'orange';
tr.cells[17].style.backgroundColor = 'orange';
tr.cells[18].style.backgroundColor = 'orange';
tr.cells[21].style.backgroundColor = 'orange';
tr.cells[22].style.backgroundColor = 'orange';
tr.cells[23].style.backgroundColor = 'orange';
tr.cells[24].style.backgroundColor = 'orange';
tr.cells[25].style.backgroundColor = 'orange';
tr.cells[26].style.backgroundColor = 'orange';
tr.cells[27].style.backgroundColor = 'orange';
tr.cells[28].style.backgroundColor = 'orange';
});
}
}
});
// table要素内のtbody要素の子要素を監視
observer.observe(table.tBodies[0], {
childList: true
});
});
})();
下記のコードでエラーが出ています。
mobile版では、仕様が異なるのでしょうか。
また、他に方法があればご教授いただけたらと思います。
// table要素内のtbody要素の子要素を監視
observer.observe(table.tBodies[0], {
childList: true