Jemt / Fit.UI

Fit.UI is a JavaScript based UI framework built on Object Oriented principles
http://fitui.org
GNU Lesser General Public License v3.0
19 stars 7 forks source link

DatePicker: Disposing control while loading calendar widget breaks all instances #193

Closed FlowIT-JIT closed 10 months ago

FlowIT-JIT commented 11 months ago

With React controls might be created and destroyed multiple times due to its re-rendering nature. If a DatePicker happens to be created and auto-opened, and immediately hereafter destroyed due to rerendering, then the loading of the calendar widget will be canceled and will not be retried again:

https://github.com/Jemt/Fit.UI/blob/1fb468230e1313df1b33a57264c348bfd35682a3/Controls/DatePicker/DatePicker.js#L1027

This check prevents the jQuery instance from being persisted below, and for additional resources to be loaded. Remove the check.

Proof: https://jsfiddle.net/yf20mhbd/

Fit.Events.OnReady(function()
{
    for (var i = 0 ; i < 2 ; i++)
    {
        var dp = new Fit.Controls.DatePicker("DP" + i); 
        dp.Width(100);
        dp.Render();
        dp.Show();

        if (i === 0)
        {
            dp.Dispose();
        }
    }
});