This last bit of code works, but I got this error when coming back to the view where I used it:
Uncaught Error: Assertion Failed: Emptying a view in the inBuffer state is not allowed and should not happen under normal circumstances. Most likely there is a bug in your application. This may be due to excessive property change notifications.