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 7728463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:43:26+00:00 2026-06-01T05:43:26+00:00

Say I have a template which displays a view based on a property: {{#if

  • 0

Say I have a template which displays a view based on a property:

{{#if App.contentsAreVisible}}
    {{view ToggleContents}}
{{/if}}

This area is toggled by any number of other parts of the UI by setting App.set("contentsAreVisible", [true/false]);

This all works fine.

However, I now want to animate when the view is toggled. Hooking into didInsertElement works to animate showing the area, but I can’t do the same in willDestroyElement because the element is removed as soon as that function returns, before the animation has a chance to run.

App.ToggleContents = Ember.View.extend({

    // this works fine
    didInsertElement: function(){
        this.$().hide().show("slow");
    },

    // this doesn't work
    willDestroyElement: function(){
        this.$().hide("slow", function(){
            // animation is complete, notify that the element can be removed
        });
    }
});

Is there any way to tell the view to defer removing the element from the DOM until the animation is complete?

Here’s a fiddle with an interactive example: http://jsfiddle.net/rlivsey/RxxPU/

  • 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-01T05:43:27+00:00Added an answer on June 1, 2026 at 5:43 am

    You could create a hide function on your view which removes the view when the callback is finished, see http://jsfiddle.net/7EuSC/

    Handlebars:

    <script type="text/x-handlebars" data-template-name="tmpl" >
        <button {{action "hide" }}>hide</button>
    
        This is my test view which is faded in and out
    </script>​
    

    JavaScript:

    Ember.View.create({
        templateName: 'tmpl',
    
        didInsertElement: function() {
            this.$().hide().show("slow");
        },
    
        _hideViewChanged: function() {
            if (this.get('hideView')) {
                this.hide();
            }
        }.observes('hideView'),
    
        hide: function() {
            var that = this;
            this.$().hide("slow", function() {
                that.remove();
            });
        }
    }).append();​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have a template class Area , which has a member variable
In my Java app I have a template string, say, This record's name is
Let's say I have a simple Server with a template which accepts a Client
Let's say you have a view called View Story which is just a web
Let's say I have a template like this <script id=rowTemplate type=text/x-jquery-tmpl> <tr> <a href=${
ok, say you have two dbs. one you use as a master template which
I have a template in which I placed, let's say 5 forms, but all
Say I have a template function in namespace A. I also have another namespace
Let's say I have some Jinja2 template with several blocks in it: {% block
Lets say have this immutable record type: public class Record { public Record(int x,

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.