How to update polymer element bindings after it was removed from DOM and inserted again

后端 未结 1 1312
粉色の甜心
粉色の甜心 2021-01-05 12:36

Assume we have container polymer element and another dummy polymer element. Container polymer element has div block for inserting another polymers.

container

相关标签:
1条回答
  • 2021-01-05 13:14

    I have not tried it myself but it seems reasonable. I hope the author doesn't mind coping his answer from Detached observables when re-using element.

    Having looked into the polymer.js information bit I have found that there is a cancelUnbindAll function which must be called when the element is created or a preventDispose property set to true.

    For anyone that might need to do the same, in the Dart implementation you must call cancelUnbindAll in the detached function after the super call, as follows:

    void detached()
    {
        super.detached();
        this.cancelUnbindAll(preventCascade: true);
    }
    

    Alternatively, you can simply override the preventDispose property in your custom element:

    bool get preventDispose => true;
    
    0 讨论(0)
提交回复
热议问题