jtsage / jtsage-datebox

A multi-mode date and time picker for Bootstrap (3&4), jQueryMobile, Foundation, Bulma, FomanticUI, and UIKit (or others)
http://datebox.jtsage.dev/
Other
474 stars 166 forks source link

Updating the date does not update the slidebox #231

Closed jpsoulsf closed 11 years ago

jpsoulsf commented 12 years ago

I finally figured out how to update the date in the datebox but it doesn't update the slidebox. The text above the slidebox has the newly set date, but the slidebox does not have a day selected. I'm expecting one of the days of the week to be selected and shown in black.

I'm using require.js and loading and rendering the datebox post pageinit.

this.$dateBox = this.$("#mydate"); this.$dateBox.datebox(); // works fine.

// trigger set to set date making sure the format matches this.$dateBox.trigger('datebox', {'method':'set', 'value': '2012-11-01'});

At this point the text is updated in the datebox, but the selected element is not correct. I expect the 1st to be highlighted and centered in the datebox.

I also tried adding this.$dateBox.val('2012-11-01') with no luck.

Is this a bug or am I doing something wrong?

jpsoulsf commented 12 years ago

I have not solved this yet, but I found that it was changing the color of the selected day. But, that selected day is not centered. If I scroll over I can see it selected. Still, I expect it to be centered when I set it programmatically just as when I click it. Still looking into it.

algorhythm commented 12 years ago

I made it like this:

Set the value to the input-field (e.g. jQuery('input[type="text"][data-role="datebox"]').val('2012-11-01');) and then refresh the datebox like this jQuery('input[type="text"][data-role="datebox"]').datebox('refresh');

And after refresh, the datebox shows the date in the input-field.

jtsage commented 11 years ago

Yes, if you are changing it like this, the 'refresh' is needed - there is a possibility of a loop if I do it for you when you change it.