Created
October 31, 2011 16:56
-
-
Save ppcano/1327997 to your computer and use it in GitHub Desktop.
View does not update the DOM when binded content is updated
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('sproutcore'); | |
var set = SC.set; | |
var get = SC.get; | |
var max = 100 | |
, i = 0 | |
, content = []; | |
module("ScrollView test", { | |
setup: function() { | |
console.group(' - Setup for new test'); | |
App = SC.Application.create({}); | |
for(i=0; i< max; i++) { | |
content.push( SC.Object.create( { position: i, name: 'asdasdf' } ) ); | |
} | |
SC.run(function() { // require for applying the binding | |
App.view = SC.CollectionView.create({ | |
tagName: 'ul', | |
classNames: ['list-scroll-view'], | |
elementId: 'myid', | |
content: content, | |
itemViewClass: SC.View.extend({ | |
template: SC.Handlebars.compile('{{content.position}} {{content.name}}') | |
}) | |
}); | |
}); | |
SC.run(function() { | |
App.view.append(); | |
}); | |
}, | |
teardown: function() { | |
content = []; | |
App.view.destroy(); | |
App.destroy(); | |
console.groupEnd(); | |
} | |
}); | |
test("should remove an item in DOM when removed an item from the content ", function() { | |
equals(SC.getPath('App.view.content').length, max, " there are items === max"); | |
equals(App.view.$('li').length, max, " there are number of li === max"); | |
SC.run(function() { | |
// HERE is the problem: _contentWill/DidChange won't be triggered | |
// use instead content.removeAt(1) --> sproutcore-runtime mutable array properties | |
content.pop(); | |
}); | |
equals(SC.getPath('App.view.content').length, max-1, " there are items === max-1"); | |
equals(App.view.$('li').length, max-1, " there are number of li === max-1"); | |
}); | |
Solved: problem because using JS array methods instead the ones ( insertAt, removedAt ) defined by SC.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the fourth assert fails:
why won't the view update the DOM?
It seems that _contentWillChange and _contentDidChange won't be triggered on CollectionView.
Is that a RunLoop or CollectionView problem?
*** using bmp and SC20