Defining functions in SproutCore fixtures
Is it possible to define a function from inside a SproutCore fixture? For example, if I wanted an array controller that changed the function applied to an object dependent on the selection. I've tried specifying an attribute in the model as below:
func: SC.Record.attr(Object)
and in the fixtures as:
{guid: 'tool-0',
func: function(){
$('domObject').append('message');
}
}
But I get:
Uncaught TypeError: Property 'func' of object App.Tool({guid: tool-开发者_高级运维0 , func: function() { ... }}) READY_CLEAN is not a function
Is the problem with my implementation or my approach here? I'm not brilliant with Javascript to begin with, and there isn't a wealth of information about using Sproutcore, so I'm struggling to tell if I'm using it correctly.
It is not possible to add functions in the fixtures file. Fixtures are designed only for holding data in the development phase of an application.
If you want to add any functions which manipulates the existing data or properties of an each object, define those functions in Model.
精彩评论