Skip to content

Changing one timepickers options while another timepicker is actively being used. #70

@phazei

Description

@phazei

If I have a timepicker window open and I'm selecting a time, then while it's open, I use an on change event to modify the options of another timepicker, the open timepicker seems to switch over to the one that just had its options changed.

Then, to force it to switch the context back, if I try to just change some uneeded option on the original picker, the picker window closes without letting me click a time after I've clicked an hour.

$('.multiplier-items').on('change', '.timepicker.time-end', function() {
    var hour = $(this).timepicker("getHour");
    var minute = $(this).timepicker("getMinute");

    var $time_start = $(this).closest('.multiplier-time-item').find('.timepicker.time-start');
    $time_start.timepicker("option","maxTime", {hour:hour,minute:minute});
    //$(this).timepicker("option","junk","nothing); //need to put focus back on this time picker in the global instance
});

If I check $.timepicker._curInst it still shows it's the one that's open, but when I click the hours or check the settings, it effects/matches the one changed in the change event, in this case the $time_start timepicker.

Seems I was able to fix it.
Near line 1099 this:

            if (inst) {
                if (this._curInst == inst) {
                    this._hideTimepicker();
                }
                extendRemove(inst.settings, settings);
                this._updateTimepicker(inst);
            }

needs to be changed to this:

            if (inst) {
                extendRemove(inst.settings, settings);
                if (this._curInst == inst) {
                    this._hideTimepicker();
                    this._updateTimepicker(inst);
                }
            }

Since all the inst share the same dialog, when it does the updateTimepicker, even though inst isn't curInst, it rebuilts the html with what's to be expected from inst and redoes the bindings, so if curInst != inst, it shouldn't update the timepicker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions