-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Silent value updates, no callbacks #279
Comments
There’s no way to do this at the moment. Why do you feel the need for this? If you want to just update the value to be formatted differently, you should be setting the Cheers. |
I need this too... the scenario is as follows: I have a pickadate whose value I set programatically with an ajax call. After loading this value, the user can change the date to what he wishes, but upon doing so an auto ajax call is made to the server to update the date. The problem is that when I set the date programatically, the onSet event is triggered which makes a pointless ajax call to the server. Isn't there a way for the onSet event to be triggered only when the user manually selects a date from the picker? Thanks. |
This is the workaround I had to create. function silent_set( picker, date ) {
picker.component.item.select = {
year: date.getFullYear()
, month: date.getMonth()
, date: date.getDate()
, day: date.getDay()
, obj: date
};
// Dat hack!!!
var value =
picker.
component.
formats.
toString.
apply(
picker.component,
[ picker.component.settings.format,
picker.component.get('select')
]);
picker.set( 'highlight', date );
picker.$node.val( value ).trigger( 'change' );
picker.render();
} |
It would be nice to update the picker value with no user interaction. For example: picker.on({
set: function () {
alert('you selected:' + e.select);
}
});
// Somewhere else
setTimeout(function(){
picker.set( 'select', new Date());
},1000); After 1 second, we don't want to alert the user of the selection, we would like to set it silently (skipping the onSet callback) |
Did you place the slient_set function in the original source file or somewhere in your js file? I agree that the ability of silent setting of dates is required specially if in the select event handler we make an ajax call to the server... Thanks... |
Added with v3.3.1: http://amsul.ca/pickadate.js/api.htm#muted-callbacks Cheers :) |
We appreciate this! Thank you very much @amsul :D |
I'm using pickadate and I need to update the value of the picker but I don't need the callback
onSet
to be triggered.Is there a way of setting 'select' without calling callbacks ?
The text was updated successfully, but these errors were encountered: