aurajs / aura

A scalable, event-driven JavaScript architecture for developing component-based applications.
MIT License
2.94k stars 255 forks source link

Component does not respond to events #303

Closed TWry closed 11 years ago

TWry commented 11 years ago

I am trying to create a component in Auro like so:

define(['text!./template.hbs'], function(template) {
  return {
    events: {
      'click a': function(e) {
         console.log('click a event triggered');
      }
    },
    initialize: function() {
        this.render();
    },
    render: function() {
        this.html(template);
    },
  }
});

The problem is that the code for the 'click a' event is never triggered. Could you point me to possible causes, please?

Thanks!

addyosmani commented 11 years ago

I would recommend looking at how we tackle this over in https://github.com/aurajs/examples/tree/master/aura-backbone-example/app. Were you using the boilerplate to create your app?

sbellity commented 11 years ago

Hey @TWry DOM 'events' handling like that is provided by Backbone. You have to add the aura-backbone extension to be able to do that.

https://github.com/aurajs/examples/blob/master/aura-backbone-example/app/extensions/aura-backbone.js

TWry commented 11 years ago

Yes, I used the boilerplate to create the app. From reading the documentation I thought I could do that without any extension but obviously I need the aura-backbone extension. Thanks!