Ladies & Gentlemen,
Short Version: Trying to dynamically create a Spine Model Class. Basically I get a JSON from the server telling me what the model name is and what it´s attributes are and then I´ll try to create a class derived from spine.model.
As Spine.js uses a Coffeescript class that is configured before being instantiated I wanted to create one dynamically - Which works, only some of the inherited functionality does not.
Problem: While inherited functions work, fetch doesn´t seem to work and there seems no way to set the class name.
Code: http://jsfiddle.net/thomasf1/eqksA/5/
It´s fascinating how far you can push Coffeescript. Thanks in advance for any clue to solving this advanced riddle.
I'm not exactly sure how Spine.js works, but looking through your code I noticed
fetch
is a class method ofCDModel
, and that's how you use it in the first test where you fetch 'static message,' but for the dynamic class you're trying to usefetch
as an instance method.I changed the name to DynamicClass for my own clarity, but I did the following:
I noticed this only works when you comment out the call to the first test though, but not being familiar with Spine.js I'm not entirely sure why this occurs.
I hope this helps. Sandro