-
Notifications
You must be signed in to change notification settings - Fork 56
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
Issue regarding Backbone and twig.js #83
Comments
I've just added a new integration test to the suite in an attempt to reproduce your problem. Here's the test I wrote:
The test passes though, so I'm pretty confident that method calls are working okay. I was wondering, have you tried using {% for model in collection.models %}
{{ model.getFoo() }}
{{ model.get( 'attr' ) }}
{% endfor %} |
Hi @Urael and thx for your answer, I did some tests : Adding the "models" attribute to the collection like : {% for model in collection.models %}
{{ model.getFoo() }}
{% endfor %} Solved the issue for something 'static' meaning outside of the this.get() getFoo: function() { return 'foo'; } Otherwise, if : getFoo() proxy a call to native Backbone.Model.get( 'myAttr' ) like : getFoo: function() {
// ...Work hard here
return this.get( 'myAttr' );
} Void is returned. Calling the native Backbone.Model.get: function( attr ) from a template thru : {% for model in collection.models %}
{{ model.get( 'attr' ) }}
{% endfor %} Still remains void. Maybe, is more a issue related to Backbone.Model... however while looking inside it's only a getter accessing to a hash. Nothing huge :) Backbone.Model.get: function(attr) {
return this.attributes[attr];
}, Best, |
This looks like it might be a symptom of issue #67. We only merged the fix for that bug ten days ago, so I wouldn't be surprised if you were using a version of Twig.js still affected by it. Would you mind updating your Twig.js to the very latest version and checking if your bug is still present? |
It rocks! Thanks to the merge And of course thanks for your advices @Urael :) Best, |
Glad to hear it :) |
Suppose that a backbone model MyModel has "public" methods such as :
Now suppose we hydrate n MyModel in a Backbone Collection MyCollection.
In a backbone View it will looks like this :
Unfortunately,
doesn't work and return void.
the only thing working right now to access attributes of a Backbone Model is to Jsonize the collection itself :
and access attrs thru :
It's restrictive... As an example the _.template() from underscore allow to access the whole methods
Is a normal behavior of twig.js ?
Best,
The text was updated successfully, but these errors were encountered: