mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
BUGFIX: leaving stray views in Ember during navigation
This commit is contained in:
parent
68600f1dce
commit
13f4afe00f
1 changed files with 24 additions and 14 deletions
38
vendor/assets/javascripts/ember-cloaking.js
vendored
38
vendor/assets/javascripts/ember-cloaking.js
vendored
|
@ -168,7 +168,7 @@
|
||||||
|
|
||||||
for (var j=bottomView; j<childViews.length; j++) {
|
for (var j=bottomView; j<childViews.length; j++) {
|
||||||
var checkView = childViews[j];
|
var checkView = childViews[j];
|
||||||
if (!checkView.get('containedView')) {
|
if (!checkView._containedView) {
|
||||||
if (!checkView.get('loading')) {
|
if (!checkView.get('loading')) {
|
||||||
checkView.$().html(this.get('loadingHTML') || "Loading...");
|
checkView.$().html(this.get('loadingHTML') || "Loading...");
|
||||||
}
|
}
|
||||||
|
@ -231,8 +231,7 @@
|
||||||
@method uncloak
|
@method uncloak
|
||||||
*/
|
*/
|
||||||
uncloak: function() {
|
uncloak: function() {
|
||||||
var containedView = this.get('containedView');
|
if (!this._containedView) {
|
||||||
if (!containedView) {
|
|
||||||
var model = this.get('content'),
|
var model = this.get('content'),
|
||||||
controller = null,
|
controller = null,
|
||||||
container = this.get('container');
|
container = this.get('container');
|
||||||
|
@ -271,10 +270,10 @@
|
||||||
if (controller) { createArgs.controller = controller; }
|
if (controller) { createArgs.controller = controller; }
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
style: null,
|
style: null,
|
||||||
loading: false,
|
loading: false
|
||||||
containedView: this.createChildView(this.get('cloaks'), createArgs)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._containedView = this.createChildView(this.get('cloaks'), createArgs);
|
||||||
this.rerender();
|
this.rerender();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -285,10 +284,9 @@
|
||||||
@method cloak
|
@method cloak
|
||||||
*/
|
*/
|
||||||
cloak: function() {
|
cloak: function() {
|
||||||
var containedView = this.get('containedView'),
|
var self = this;
|
||||||
self = this;
|
|
||||||
|
|
||||||
if (containedView && this.get('state') === 'inDOM') {
|
if (this._containedView && this.get('state') === 'inDOM') {
|
||||||
var style = 'height: ' + this.$().height() + 'px;';
|
var style = 'height: ' + this.$().height() + 'px;';
|
||||||
this.set('style', style);
|
this.set('style', style);
|
||||||
this.$().prop('style', style);
|
this.$().prop('style', style);
|
||||||
|
@ -296,16 +294,24 @@
|
||||||
// We need to remove the container after the height of the element has taken
|
// We need to remove the container after the height of the element has taken
|
||||||
// effect.
|
// effect.
|
||||||
Ember.run.schedule('afterRender', function() {
|
Ember.run.schedule('afterRender', function() {
|
||||||
self.set('containedView', null);
|
if(self._containedView){
|
||||||
containedView.willDestroyElement();
|
self._containedView.remove();
|
||||||
containedView.remove();
|
self._containedView = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
willDestroyElement: function(){
|
||||||
|
if(this._containedView){
|
||||||
|
this._containedView.remove();
|
||||||
|
this._containedView = null;
|
||||||
|
}
|
||||||
|
this._super();
|
||||||
|
},
|
||||||
|
|
||||||
didInsertElement: function(){
|
didInsertElement: function(){
|
||||||
if (!this.get('containedView')) {
|
if (!this._containedView) {
|
||||||
// setting default height
|
// setting default height
|
||||||
// but do not touch if height already defined
|
// but do not touch if height already defined
|
||||||
if(!this.$().height()){
|
if(!this.$().height()){
|
||||||
|
@ -325,12 +331,16 @@
|
||||||
@method render
|
@method render
|
||||||
*/
|
*/
|
||||||
render: function(buffer) {
|
render: function(buffer) {
|
||||||
var containedView = this.get('containedView');
|
var containedView = this._containedView;
|
||||||
|
|
||||||
if (containedView && containedView.get('state') !== 'inDOM') {
|
if (containedView && containedView.get('state') !== 'inDOM') {
|
||||||
|
containedView.triggerRecursively('willInsertElement');
|
||||||
containedView.renderToBuffer(buffer);
|
containedView.renderToBuffer(buffer);
|
||||||
containedView.transitionTo('inDOM');
|
containedView.transitionTo('inDOM');
|
||||||
Em.run.schedule('afterRender', function() {
|
Em.run.schedule('afterRender', function() {
|
||||||
containedView.didInsertElement();
|
if(this._containedView) {
|
||||||
|
this._containedView.triggerRecursively('didInsertElement');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue