Joshua Enfield
Joshua Enfield

Reputation: 18288

Is there an elegant way to run some code after the template for a component is loaded in Aurelia?

I am new to ES6 and Aurelia. I would like to execute some code after a template for a component loads. What I'm trying to do is get the page down editor working inside an Aurelia component. The imports seem to work for the most part (although Sanitizer doesn't seem to be imported), but I'm not sure how to run my initialization code after the template loads.

import 'Markdown.Converter'
import 'Markdown.Sanitizer'
import 'Markdown.Editor'

export class AddProject {
    constructor(){

    }
}

// initialization code
var converter1 = new Markdown.Converter();//Markdown.getSanitizingConverter(); // commented out doesn't work
var editor1 = new Markdown.Editor(converter1);
editor1.run();

I just want to run my initialization code for the template after it get's loaded into the dom. Any ideas?

Upvotes: 3

Views: 527

Answers (1)

JamesCarters
JamesCarters

Reputation: 771

Use attached

export class MyClass{
    attached(){
        alert('My template is attached');   
    }        
}

Upvotes: 3

Related Questions