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
TextBinding unbind needs to add original el.textContent back in place #623
Comments
@tanshul22 Your example is pretty cool, but very complex. Can you boil it down to just a I am interested in helping you. But your example is much too complex to isolate rivets alone as the issue. |
Thanks for looking into this @Duder-onomy. This issue is exasperated by #622 and thus the update to I've created a much simpler version of the bug here. As you'll notice The solution that works for me is to
|
I'm curious : what is the use case where you need to unbind the view and rebind it later? When i unbind a view it's to overwrite the template before performing a new bind Nevertheless your solution will work, but I would do it like this for simplicity reasons class Rivets.TextBinding extends Rivets.Binding
constructor: (@view, @el, @type, @keypath, @options = {}) ->
[...]
@originalTextContent = @el.textContent
unbind: =>
super
@el.textContent = @originalTextContent I did not test it, but it should do the job. |
Hi @jccazeaux. I like your suggestion of saving off the originalTextContent. I'll give that a shot. To answer your question, the real problem is better described in the original example which wraps up the text elements inside an |
I updated your fiddle here |
You're absolutely right! I can no longer recreate the original bug in my app. I have several nested if blocks and this was a corner case. I did my best by replicating it in the original fiddle but the I'll keep experimenting and keep this thread updated with my findings. Thanks for helping out. |
The
TextBinding
template needs to be reset uponunbind
. This comes in handy when dealing withTextBinding
in a nested view. I've demonstrated this by explicitly unbinding the view in the JSFiddle below.https://jsfiddle.net/havessex/1/
The text was updated successfully, but these errors were encountered: