March 2010
6 posts
View complete objects using addProbe
Trying to debug observers and bindings in a SproutCore application? First, call addProbe on any interesting keys:
MyApp.MyView = SC.View.extend({
init: function () {
sc_super();
this.addProbe('layout');
this.addProbe('frame');
}
});
Then, open up sproutcore/frameworks/runtime/mixins/observable, and change this:
SC.logChange = function logChange(target, key, value) {
...
Using SC.ControlTestPane? Does your app GUI show...
If you’re using SC.ControlTestPane to write unit tests for your views (more on this later, perhaps), and you see your main application GUI appearing where your tests belong, then you may have a syntax error in your JavaScript. Check your console for error messages.
Page through an SC.ListView with the spacebar
Would you like to page down through an SC.ListView with the spacebar? Try this:
MyApp.CustomScrollView = SC.ScrollView.extend({
contentView: SC.ListView.design({
// ...bindings, etc., go here...
keyDown: function(evt) {
if (SC.PRINTABLE_KEYS[evt.charCode] === ' ') {
var scroll_view = this.getPath('parentView.parentView');
scroll_view.scrollBy(0,...
Does SproutCore take 30 seconds to reload under...
For some reason, reloading a SproutCore app under sc-server may take 20 or 30 seconds. If this happens to you, try:
sudo gem install thin
This should get reload times down to a couple of seconds.
Tom Dale: How to apply a style to the current...
Tom Dale explains how to apply a style to the current input field:
.sc-text-field-view.focus input {
color: red;
}
Testing SproutCore with Cucumber + Selenium
This isn’t really a complete tutorial; just a few tricks to make the process a lot easier.
First, add the following code to features/support/env.rb, replacing existing bits as necessary:
Webrat.configure do |config|
config.mode = :selenium
config.application_environment = Rails.env
# Same as script/server, so SproutCore can proxy to the same port in both
# development and test...