Skip to content

Commit 29f83c9

Browse files
trentrichardson#782 Part 2 - Adds afterInject option as function
1 parent 38589ab commit 29f83c9

5 files changed

+38
-4
lines changed

dist/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ <h3>Other Options</h3>
345345
<dt>timeOnlyShowDate</dt>
346346
<dd><em>Default: false</em> - Show the date and time in the input, but only allow the timepicker.</dd>
347347

348+
<dt>afterInject</dt>
349+
<dd><em>Default: null</em> - Function to be called when the timepicker or selection control is injected or re-rendered. Called in the context of the timepicker instance.</dd>
350+
348351
<dt>onSelect</dt>
349352
<dd><em>Default: null</em> - Function to be called when a date is chosen or time has changed (parameters: datetimeText, datepickerInstance).</dd>
350353

dist/jquery-ui-timepicker-addon.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
controlType: 'slider',
104104
oneLine: false,
105105
defaultValue: null,
106-
parse: 'strict'
106+
parse: 'strict',
107+
afterInject: null
107108
};
108109
$.extend(this._defaults, this.regional['']);
109110
};
@@ -313,6 +314,7 @@
313314
this.timeDefined = this._parseTime(currDT);
314315
this._limitMinMaxDateTime(dp_inst, false);
315316
this._injectTimePicker();
317+
this._afterInject();
316318
},
317319

318320
/*
@@ -349,6 +351,16 @@
349351
}
350352
},
351353

354+
/*
355+
* Handle callback option after injecting timepicker
356+
*/
357+
_afterInject: function() {
358+
var o = this.inst.settings;
359+
if ($.isFunction(o.afterInject)) {
360+
o.afterInject.call(this);
361+
}
362+
},
363+
352364
/*
353365
* generate and inject html for timepicker into ui datepicker
354366
*/
@@ -494,6 +506,7 @@
494506
this.timezone_select.change(function () {
495507
tp_inst._onTimeChange();
496508
tp_inst._onSelectHandler();
509+
tp_inst._afterInject();
497510
});
498511
// End timezone options
499512

@@ -1052,6 +1065,7 @@
10521065
$(sel).appendTo(obj).change(function (e) {
10531066
tp_inst._onTimeChange();
10541067
tp_inst._onSelectHandler();
1068+
tp_inst._afterInject();
10551069
});
10561070

10571071
return obj;

dist/jquery-ui-timepicker-addon.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/options.html

+3
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ <h3>Other Options</h3>
209209
<dt>timeOnlyShowDate</dt>
210210
<dd><em>Default: false</em> - Show the date and time in the input, but only allow the timepicker.</dd>
211211

212+
<dt>afterInject</dt>
213+
<dd><em>Default: null</em> - Function to be called when the timepicker or selection control is injected or re-rendered. Called in the context of the timepicker instance.</dd>
214+
212215
<dt>onSelect</dt>
213216
<dd><em>Default: null</em> - Function to be called when a date is chosen or time has changed (parameters: datetimeText, datepickerInstance).</dd>
214217

src/jquery-ui-timepicker-addon.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
controlType: 'slider',
110110
oneLine: false,
111111
defaultValue: null,
112-
parse: 'strict'
112+
parse: 'strict',
113+
afterInject: null
113114
};
114115
$.extend(this._defaults, this.regional['']);
115116
};
@@ -319,6 +320,7 @@
319320
this.timeDefined = this._parseTime(currDT);
320321
this._limitMinMaxDateTime(dp_inst, false);
321322
this._injectTimePicker();
323+
this._afterInject();
322324
},
323325

324326
/*
@@ -355,6 +357,16 @@
355357
}
356358
},
357359

360+
/*
361+
* Handle callback option after injecting timepicker
362+
*/
363+
_afterInject: function() {
364+
var o = this.inst.settings;
365+
if ($.isFunction(o.afterInject)) {
366+
o.afterInject.call(this);
367+
}
368+
},
369+
358370
/*
359371
* generate and inject html for timepicker into ui datepicker
360372
*/
@@ -500,6 +512,7 @@
500512
this.timezone_select.change(function () {
501513
tp_inst._onTimeChange();
502514
tp_inst._onSelectHandler();
515+
tp_inst._afterInject();
503516
});
504517
// End timezone options
505518

@@ -1058,6 +1071,7 @@
10581071
$(sel).appendTo(obj).change(function (e) {
10591072
tp_inst._onTimeChange();
10601073
tp_inst._onSelectHandler();
1074+
tp_inst._afterInject();
10611075
});
10621076

10631077
return obj;

0 commit comments

Comments
 (0)