I have these two classes:
class CoconutMobile.Thumbnail extends Batman.Model
@belongsTo 'file', inverseOf: 'thumbnail'
class CoconutMobile.File extends Batman.Model
@hasOne 'thumbnail', inverseOf: 'file'
In have a thumbnail partial:
<div class="thumbnail" data-event-click="destroyFile | withArguments thumbnail.file">
<img data-bind-src="thumbnail.data">
</div>
and a controller method:
destroyFile: (file) ->
file.destroy()
However, this doesn't work. This last line of code throws an error because the destroy method is undefined. The controller method is called with a BelongsToProxy, which doesn't have a destroy() method. I can retrieve properties of the file object, if I use file.get('name'), it correctly returns the file's name. And if I use
file.get('target').destroy()
it works fine as well. But then the controller method would never work if the destroyFile method would be called with a plain File object. Shouldn't the proxy re-route these method calls to target? Or am I missing something?
--
You received this message because you are subscribed to the Google Groups "batman.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to batmanjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<div data-context-realitem='item.target | default item'>
<a data-event-click='editItem | withArguments realitem'></a>
</div>
Hi,Thanks for sharing this issue.
I think you're right -- the proxy should route these calls to the target. Using belongsToProxies everywhere is pretty new (started in 0.16), which is why this hasn't popped up yet.
Let's track the issue here: https://github.com/batmanjs/batman/issues/1061In the mean time, I recommend working around it by explicitly pointing to target:<div data-event-click='destroyFile | withArguments thumbnail.file.target'></div>That's what we're doing now to work around some of the ambiguity of belongsToProxy (eg, `data-showif='belongsTo.target`). How does that work for you?robert
I'm experiencing some trouble getting some Batman models to work using a belongsTo relationship. I'm using Batman v0.16.
I have these two classes:
class CoconutMobile.Thumbnail extends Batman.Model
@belongsTo 'file', inverseOf: 'thumbnail'
class CoconutMobile.File extends Batman.Model
@hasOne 'thumbnail', inverseOf: 'file'
In have a thumbnail partial:
<div class="thumbnail" data-event-click="destroyFile | withArguments thumbnail.file">
<img data-bind-src="thumbnail.data">
</div>
and a controller method:
destroyFile: (file) ->
file.destroy()
However, this doesn't work. This last line of code throws an error because the destroy method is undefined. The controller method is called with a BelongsToProxy, which doesn't have a destroy() method. I can retrieve properties of the file object, if I use file.get('name'), it correctly returns the file's name. And if I use
file.get('target').destroy()
it works fine as well. But then the controller method would never work if the destroyFile method would be called with a plain File object. Shouldn't the proxy re-route these method calls to target? Or am I missing something?
--
You received this message because you are subscribed to the Google Groups "batman.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to batmanjs+unsubscribe@googlegroups.com.