attached , DOM "" DOM. , repeat ed , , - :
import {inject, TaskQueue} from 'aurelia-framework';
@inject(TaskQueue)
export class MyComponent {
constructor(taskQueue) {
this.taskQueue = taskQueue;
}
doSomethingAfterRepeatIsRendered() {
}
attached() {
this.taskQueue.queueMicroTask({
call: () => this.doSomethingAfterRepeatIsRendered();
});
}
}
, , , <li>, . TaskQueue , , . , jQuery <li>, " aurelia" , :
-something.js
import {inject, customAttribute} from 'aurelia-framework';
import $ from 'jquery';
@customAttribute('do-something')
@inject(Element)
export class DoSomethingCustomAttribute {
constructor(element) {
this.element = element;
}
attached() {
$(this.element).doSomething(this.value);
}
}
:
app.html
<template>
<require from="./do-something"></require>
<ul>
<li repeat.for="thing of things" do-something.bind="thing"></li>
</ul>
</template>