Deferring removal of a view so it can be animated

前端 未结 2 396
南旧
南旧 2021-01-03 00:49

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

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

This ar

2条回答
  •  余生分开走
    2021-01-03 01:20

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

    Handlebars:

    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();​
    

提交回复
热议问题