Firebug is showing error in the controller Sproutcore 2

52 Views Asked by At

I would appreciate it if someone can help me resolve this issue. I am following the online guides and am very new to Sproutcore. I have created a "HelloWorld" project and have generated HelloWorld.appController. In appController, I have declared a function called sayHello. When I refresh the site on the localhost:4020/hello_world, firebug shows an error, I have been searching online for this issue and have not found any answers. I have cleaned the browser(FF) cache a few times and no luck.Firebug reports that "sayHello" function is missing a "}" which is not true. If I comment the sayHello function out and query the "greeting" variable of appController, I am able to look it up. As soon as I place the sayHello function back in, "greeting" variable disappears from my view and firebug complains. Thank you for all your help.

ERROR: missing } after property list sayHello: function(){ app_co...0236609 (line 21, col 2)

Here is the appController code:

// ==========================================================================
// Project:   HelloWorld.appController
// Copyright: @2012 My Company, Inc.
// ==========================================================================
/*globals HelloWorld */

/** @class

(Document Your Controller Here)

@extends SC.Object
*/
HelloWorld.appController = SC.ObjectController.create(
/** @scope HelloWorld.appController.prototype */ {

// TODO: Add your own code here.

greeting: "HEY NOW!!!"

//FUNCTION SAYHELLO

sayHello: function(){
var currentGreeting = this.get('greeting');
var newGreeting = (currentGreeting === 'Hello World!') ? 'I am on SproutCore!' : 'Hello World!' ;
this.set('greeting', newGreeting);
  }
});   
1

There are 1 best solutions below

2
On BEST ANSWER

This error almost always means that you missed a comma after defining one of your properties. In this case, it is your greetings property.

Just add a comma at the end of the line and you should be good.

Also, a quick note, SproutCore went through some changes recently and "SproutCore 2" split off into its own project called EmberJS. They both have much of the same foundation and features, so getting started with either should give you a good idea of how both work, excepts that TemplateViews are more prominent in Ember than in SproutCore.