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

Closed
rwaldin opened this Issue Jun 24, 2013 · 3 comments

Comments

Projects
None yet
4 participants
@rwaldin

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

This comment has been minimized.

Show comment
Hide comment
@demyanrogozhin

demyanrogozhin Sep 9, 2013

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.

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

This comment has been minimized.

Show comment
Hide comment
@azazel75

azazel75 Oct 11, 2013

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/

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

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Oct 12, 2013

Contributor

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 :)

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