Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.

Conversation

@moshfeu
Copy link

@moshfeu moshfeu commented Feb 15, 2016

Now, when you are calling to callback you get the main object like
"afterDone: function(element) {
console.log(element, "after done");
}"

Now, when you are calling to callback you get the main object like
"afterDone: function(element) {
console.log(element, "after done");
}"
@RobinHoutevelts
Copy link

+1
I was about to create my own PR.

Without the context set it's impossible to know which clockpicker fired the callback.
Although I simply added at line 354

var noop = function () {};
var isFunction = function (callbackFunction) {
    return callbackFunction && typeof callbackFunction === "function";
};

[
    'init', 'beforeShow', 'afterShow', 'beforeHide', 'afterHide',
    'beforeHourSelect', 'afterHourSelect', 'beforeDone', 'afterDone'
].forEach(function(callbackName){
    var callback = this.options[callbackName];
    callback = isFunction(callback) ? callback.bind(this) : noop;
    this.options[callbackName] = callback;
}.bind(this));

Imo it's cleaner as you don't have to change the prototype. The forEach could be replaced with a regular loop in case you need to support IE8.

Anyway, guess it doesn't matter much as this project doesn't seem to be maintained anymore. So I'll just leave it here for others to find.

@arthur-alves
Copy link

Merge this please, we need.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants