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

error passing can.Observe.List to custom Mustache element helper #438

Closed
rwaldin opened this issue Jun 24, 2013 · 3 comments · Fixed by #496
Closed

error passing can.Observe.List to custom Mustache element helper #438

rwaldin opened this issue Jun 24, 2013 · 3 comments · Fixed by #496
Assignees
Milestone

Comments

@rwaldin
Copy link

rwaldin commented Jun 24, 2013

I'm trying to pass a can.Observe.List to a custom Mustache element helper as a parameter and I get this error:

[can.zepto:3590] TypeError: 'undefined' is not a function (evaluating '(newVal || "").replace(/['"]/g, '')')

Here's a demonstration of the problem: http://jsfiddle.net/rwaldin/qc3XZ/

Uncomment the helper in the first list item to see the problem.

@demyanrogozhin
Copy link

Sorry for bumping old issue, but I faced same error.
And that's what I wound:

First of all - generated template is wrong - no can.view.pending() called after adding first tag.
I added work around: http://jsfiddle.net/qc3XZ/6/

Second - for Observable data types (data.isListening is true) helper return value added on mustache stack, which result invalid HTML :

  < li function(el) { if //..and so on }  data-view-id='2'> observeList broken < /li > "

Third - compete-function can return function, but do not call OR even check value is not valid object.

My summary:
Using helper that return function for observable objects is bad idea.

@azazel75
Copy link

i really don't know what the previous commenter means with "- no can.view.pending() called after adding first tag" but i've used a can.zepto.js compiled with sources containing my patch for bug #463 and it seems to work, check it out: http://jsfiddle.net/qc3XZ/9/

@ghost ghost assigned daffl Oct 12, 2013
@daffl
Copy link
Contributor

daffl commented Oct 12, 2013

Thanks for the update! I will check the fix and hopefully manage to write tests for all the issues. Lets hope it works for all cases :)

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

Successfully merging a pull request may close this issue.

4 participants