BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
856 stars 130 forks source link

helper does not get updated when "nested" linking #393

Closed ainglese closed 6 years ago

ainglese commented 6 years ago

Hi boris, i think i've spot a bug, but i'm not sure if this is a supported scenario; the effect is that the value from an helper does not get updated when re-linking an element, when that element is inside another linked template.

here's a fiddle with a repro for the issue: https://jsfiddle.net/494vvhj8/ (jsviews v .88)

note that the issue does not seem to happen in version .84, but happens surely in .86 and .88 https://jsfiddle.net/v43oqo77/1/ (jsviews v .84 - UPDATED, had wrong version of jsviews)

maybe something has changed when disposing the linked view or the helper is not getting updated when re-linking..

i've also found a workaround, removing the element i'm linking to and re-adding after linking seems to "solve" the issue.

BorisMoore commented 6 years ago

Thanks for calling this out!

Yes, it is a bit of an edge case, but still, ideally I would like to support it, and provide a fix. It is actually rather complex, but I think I have a working fix now. I'll post it here in a day or two.

BorisMoore commented 6 years ago

Here is a proposed fix. Let me know if it doesn't fix the problem, or if you see other issues. Thanks!

jsviews.js.txt (updated)

BorisMoore commented 6 years ago

Ah I found an issue with my earlier fix. I replaced it with an update, above...

BorisMoore commented 6 years ago

This has been fixed in commit 89