* Rerenders the view. * @return {View} Fluent interface
()
| 81 | * @return {View} Fluent interface |
| 82 | */ |
| 83 | refresh () { |
| 84 | const $oldRoot = this._$root |
| 85 | if ($oldRoot === null) { |
| 86 | // only refresh if there is an existing element |
| 87 | return this |
| 88 | } |
| 89 | |
| 90 | // render |
| 91 | this._$root = null |
| 92 | this.willRender() |
| 93 | this._$root = this.render() |
| 94 | this.didRender() |
| 95 | |
| 96 | // append each subview to new root element |
| 97 | this.getSubviews().forEach(this.appendSubviewElement) |
| 98 | |
| 99 | // replace root node in dom |
| 100 | if ($oldRoot && $oldRoot.parentNode) { |
| 101 | $oldRoot.parentNode.replaceChild(this._$root, $oldRoot) |
| 102 | } |
| 103 | |
| 104 | return this |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Renders the view. |
no test coverage detected