Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9177687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:22:59+00:00 2026-06-17T17:22:59+00:00

I have this working jsfiddle . The EmBlog.PostsEditRoute has a destroyPost event which I

  • 0

I have this working jsfiddle. The EmBlog.PostsEditRoute has a destroyPost event which I want to call with an action helper in the ‘post/show.hbs’ which is the template for the EmBlog.PostsShowRoute.

I am using #with helper to change scope in the template as suggested here. It doesn’t destroy the object and throws no error.

 <script type="text/x-handlebars" data-template-name="posts/show">
   {{#with EmBlog.PostsEditController}}
      <a href='#' {{action destroyPost this}}> Destroy</a>
   {{/with}}
 </script>

 EmBlog.PostsShowRoute = Ember.Route.extend({

 });

 EmBlog.PostsEditRoute = Ember.Route.extend({
    events: {
      destroyPost: function(context) {
       var post = context.get('content'); 
        post.deleteRecord();
        post.get('store').commit();
        this.transitionTo('posts');
      }
    }
 });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:22:59+00:00Added an answer on June 17, 2026 at 5:22 pm

    I think this is basically because you have to define your event handler in the EmBlog.PostsShowRoute or in the PostsRoute if you want it to be accessible in an other PostsXXX view. see http://emberjs.com/guides/templates/actions/ for details.

    (the use of the #with helper here seems wrong here BTW, as your reference is about something quite old). I would simply do

    <script type="text/x-handlebars" data-template-name="posts/show">
      <a {{action destroyPost content}}> Destroy</a>
    </script>
    

    Here is the modified fiddle: http://jsfiddle.net/Qn3ry/4/

    Note that when you try to destroy a post which is in the fixtures, it reappears when you transition to posts/index. This is simply because the post is not destroyed in the fixtures, and when entering to the PostIndexRoute, App.Post.find() will reload it again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this jsfiddle which uses toggle event - not to be confued with
I have this working example fiddle of ember routing http://jsfiddle.net/C7LrM/102/ I want to change
I have this code http://jsfiddle.net/xNHKP/6/ (not working in the fiddle for some reason which
http://jsfiddle.net/CbL7W/ example of scroll event behavior. I have this script that is working correctly
I have this code working: http://jsfiddle.net/Q2tFx/ $.fn.capitalize = function () { $.each(this, function ()
I have this code below which creating a background radial circle gradient. it's working
I have this code I'm working on, see link: http://jsfiddle.net/PqsAD/3/ The problem is depending
I currently have this working fiddle - http://jsfiddle.net/B8Abd/ I would like to use jquerys
I currently have this, it was working in jsFiddle, though its giving me errors,
Hi everyone i have this fully working code on jsfiddle: http://jsfiddle.net/Scanu/DhpXN/ But it's not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.