Open mangeshskulkarni opened 9 years ago
+1
I just added my own clearValue method, which you can call via $(el).combodate('clearValue')
Seems to do the trick.
clearValue: function() {
var that = this;
$.each(this.map, function(k, v) {
if(that['$'+k]) {
that['$'+k].val("");
}
});
this.datetime = null;
},
+1
@mbreuer23. Would you mind at all elaborating on your fix for a js noob? Where would you place that snippet of code you provided?
I put it in comdodate.js, inside the definition for Combodate.prototype. So for example, you could put it immediately before the getValue function
//.....
/*
fill ampm
*/
fillAmpm: function() {
// ...
},
clearValue: function() {
// paste code here
},
/*
Returns current date value from combos.
If format not specified - `options.format` used.
If format = `null` - Moment object returned.
*/
getValue: function(format) {
// .....
} ,
// ......
Thank you sir, @mbreuer23, works like a charm. Really appreciate your help.
nice work! thanks a lot.
Excellent works! I do recommend you to use this value in the setValue function as well, so that setValue(null) will trigger the clearValue
i also added this to my fork https://github.com/jo-soft/combodate
Hi,
Can you please guide me how I can clear the value of a Combodate whose value is already set. I tried using $('#date').combodate('setValue',''); but this did not do the trick.
Thanks