Skip to content
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

can.stache helpers that rely on array replacement don't work, but work in can.mustache #1652

Closed
imjoshdean opened this issue Apr 29, 2015 · 1 comment · Fixed by #1655
Closed
Labels
Milestone

Comments

@imjoshdean
Copy link
Contributor

Found this issue earlier today. In a component, if you have a mustache helper that relies on running on a list's length changing, and you replace the list outside of the component - everything works just fine.

If you do this using Stache...the helper stops running.

Example (can.mustache): http://jsfiddle.net/imjoshdean/ojrhg955/
Example (can.stache): http://jsfiddle.net/imjoshdean/ojrhg955/1/

@akagomez
Copy link
Contributor

Essentially, a Stache helper's binding on a list will break if the list is overwritten.

// Helper
isListEmpty: function (options) {
  return ! this.attr('items.length') ? options.fn() : options.inverse(); 
}
// Template
{{#each items}}
  ...
{{/each}}
{{#isListEmpty}}
  There are no items!
{{/isListEmpty}}
scope.attr('items', new can.List([ ... ])); // Breaks helper binding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants