Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

help with emberjs routes

In index.html, we've set up a template with a photo. In the CharlesBarkleyController, create an action that shows an alert box when the photo is clicked.

my code:

<script type="text/x-handlebars" id="charles-barkley">
    <h1>Charles "Bark"ley</h1>
    <p>Click Charles's photo to see more information about him!</p>
    <p><img src='puppies/charles_barkley.jpg' alt='A photo of Charles Barkley' {{action 'showInfo'}}></img></p>
  </script>

http://teamtreehouse.com/library/emberjs/controllers/challenge-controller-routes-and-templates

I edited you post with Markdown so it would display properly. You can do this too, just check out the Markdown Cheatsheet link above the Post button to see how :D

2 Answers

Can we see what you have tried in the app.js file? This is where the, ahem, action takes place :P

Yes can we see the code (because this is the only forum thread I could find using a google search for 'CharlesBarkleyController'.

Ah well..I guess I'll have to wing it myself.

About time index 1:49 seconds into this video: http://teamtreehouse.com/library/emberjs/controllers/routes-and-templates

...there's some code that looks like:

actions: {
   showRealName: function() {
    alert('Alert!')
  }
 }
});

I tried that and it gave me:

Bummer! You need to assign a function to the 'showInfo' property within the actions section of your controller.

So I switched it to use 'showInfo' instead, making the code look like:

AnimalShelter = Ember.Application.create();

AnimalShelter.Router.map(function() {
  this.resource('charles-barkley');
});

AnimalShelter.IndexRoute = Ember.Route.extend({
  renderTemplate: function() {
    this.render('charles-barkley');
  }
});

AnimalShelter.CharlesBarkleyController = Ember.Controller.extend({
  actions: {
    // your code goes here
     showInfo: function() {
      alert('Alert!')
     }
  }
});

I guess you could do something fancier (and I didn't touch the index.html) but this passed, so... :neutral_face: