dan
dan

Reputation: 2957

How do you get a custom element to load using Aurelia

I have a custom element like the nav-bar in the skeleton-navigation except I am not using the router part. I can't seem to get it to fire any events.

Code: nav-bar.html

<template>
  <ul id="topMenu"></ul>
</template>

nav-bar.js

 attached() {
    alert('test')
  }

Containing page:

<template>
  <require from="./nav-bar.html"></require>

  <div class="desktop" id="container">
     <nav-bar></nav-bar>
  </div>

</template>

Upvotes: 0

Views: 80

Answers (1)

Ashley Grant
Ashley Grant

Reputation: 10897

When you load the custom element using .html at the end of the path, Aurelia does not load the .js file. Just change your require element to the following, and it will work as you expect:

 <require from="./nav-bar"></require>

Upvotes: 3

Related Questions