-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't play nice with CoffeeScript class/extends syntax. #91
Comments
Ah, thanks.. that's not very nice :. I just removed the section from the readme explaining how to work around this. It sort of looks like using the Coffeescript There's three possible workaround that I can see:
I'll keep this open until I've noted these in the docs. |
–Douwe On 25 mrt. 2012, at 23:02, Paul [email protected] wrote:
Yup, that's exactly what's happening.
This is certainly a solution, but as mentioned this would kill a big part of why I (and presumably others use CoffeeScript: the nice features available when subclassing, like easily calling super.
Would work, but far from ideal. The reverseRelation property is there for a reason after all.
I think this is what I'll be going with till I think of a better way to hook into the CoffeeScript class definition process. But I think there's one thing we're forgetting: the overridden extend method doesn't just initialize the reverseRelations, it also sets the model option fir all of the new relation's to the newly defined subclass, which is very important when using subclasses of subclasses of Backbone.RelationalModel. I guess I would have to do setting of model manually.
Don't you think it'd be good to keep this open even after that? I'm still kind of hopeful someone will come up with a way to actually fix in some clever way, rather than add a notice, use a workaround and be done with it.
|
Iv'e tried using the workaround where I define a class and then create an empty placeholder but I get this error:
Where
Is not defined. |
Solution: Call |
after creating or after defining? |
When using Backbone-relational with CoffeeScript, creating a
Backbone.RelationalModel
subclass using the CoffeeScriptclass
/extends
syntax doesn't work properly, as the reverse relation initialization inBackbone.RelationalModel.extend()
is never called. Note that this syntax does work when subclassingBackbone.Model
, as this doesn't have any special logic in its.extend()
method.CoffeeScript users currently have to use:
instead of:
Losing the slightly nicer syntax isn't so bad, weren't it for the fact that this means you can't use cool CoffeeScript things like
super
and the@static: value
syntax for setting static variables either.This isn't a problem with Backbone-relational per se, but it would be nice to find a way around this problem so that CoffeeScript users will be able to use the combination of Backbone-relational and CoffeeScript to the fullest extent. This issue is here so that hopefully someone will come up with a nice solution. Maybe it'll be me, but I thought I'd share it here with the community so that others are aware of this not working and can think about a solution as well.
In the mean time, I think it'd be a good idea to place a Note in the README pointing out that the CoffeeScript syntax doesn't work yet, so that people won't get a nasty surprise when their reverse relations aren't working properly. There are a lot of people that could be having problems with this, seeing how many people are using Backbone.js with CoffeeScript: Google search for "backbone coffeescript".
The text was updated successfully, but these errors were encountered: