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 Ember.js Ember Data Creating and Deleting Records

W. Perry Wortman
W. Perry Wortman
22,087 Points

Possible bug re:new blog posts?

Hi there,

I noticed that when I go to input a second new post that the previous post's title and body are still there. This is remedied when I refresh the page, but I was just curious:

How would one avoid this without having to refresh the page(assuming there are no errors in my code)?

https://github.com/perrywortman/emberBlogger

Cheers, Perry

1 Answer

Artem Syromiatnikov
Artem Syromiatnikov
4,706 Points

I've found a solution, though it doesn't look like an elegant one. After saving the new item in NewPostController, clean the controller properties:

this.setProperties({ title: "", body: "" });

I suspect we can also create NewPostRoute and provide empty model from model method:

model: function() {
  return { title: "", body: "" };
}

Anyway I'm really looking forward to find the right way to do it.