This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Updating to latest JQuery UI and datepicker is causing the datepicker to always be seen
This is what my code looks like in JavaScript
$(function() {
$("#datepicker").datepicker({ minDate: new Date(2012,7,23), maxDate: new Date(2012,11,14)});
$("#datepicker").datepicker("setDate", new Date());
});
except that when I load it, the datepicker calendar automatically shows up at the bottom of the page. I tried the solution from here but it doesn't work. I also have the datepicker inside an accordion. Would that be part of the problem? Please let me know of any solutions. Thanks!
I have found the solution in this question Updating to latest JQuery UI and datepicker is causing the datepicker to always be seen:
$(function() {
$("#datepicker").datepicker({ minDate: new Date(2012,7,23), maxDate: new Date(2012,11,14)});
$('#ui-datepicker-div').css('display','none');
$("#datepicker").datepicker("setDate", new Date());
});
Related
I implemented the jQuery UI datepicker in my site and noticed I couldn't click 'back' to the previous month.
My HTML:
<input type='text' id='date'>
the init script:
$( '#date' ).datepicker( {
numberOfMonths: 4,
showCurrentAtPos: 1,
showButtonPanel: true
} );
I created a jsFiddle with jquery-ui-1.12.1 loading which replicated above problem. I solved it for now my switching to jquery-ui-1.9, but I'd like to be able to use the latest version. Is there anything that can be done to fix this problem?
I did some extensive debugging, the 'prev' button event is being launched, it just doesn't appear to call the update function with the right data, causing the datepicker to be updated with the same month first as it's showing before the click.
I'm starting to think this is a bug, if I set showCurrentAtPos to 0 instead of 1 the datepicker does work as expected (jsFiddle)
Was able to replicate the issue using jQuery 1.12.4 & UI 1.12.1, matching Demo versions: http://jqueryui.com/datepicker/. Working test: https://jsfiddle.net/Twisty/wkpvbp5u/
If I comment out showCurrentAtPos, it works as expected.
JavaScript
$(function() {
$('#date').datepicker({
numberOfMonths: 4,
//showCurrentAtPos: 1,
showButtonPanel: true
});
});
So the issue may be in behavior of this option. I broke it more by setting the value to -1 as a test too. The Next button fails.
Found: https://bugs.jqueryui.com/ticket/15129 so looks like you can use jQuery UI 1.11.4 but not 1.12.1. Might be a fix: https://github.com/jquery/jquery-ui/commit/17404ced478a235651513fa7bef3473ef1b039e8
Hope that helps.
I am trying to implement the solution here: Highstock + Bootstrap datepicker but I end up with an Undefined error in my console.
jsFiddle: http://jsfiddle.net/rlsaj/r6es2jyc/.
setTimeout(function () {
$('input.highcharts-range-selector', $(chart.container).parent())
.datepicker({
format: "dd/mm/yyyy",
todayBtn: "linked",
orientation: "auto left",
autoclose: true,
todayHighlight: true
});
}, 0);
My goal is to implement the Angular Bootstrap datepicker (http://angular-ui.github.io/bootstrap/) but I think I can solve that if the above fiddle can be fixed.
1.) bootstrap requires a more recent jQuery version.
2.) bootstrap does not contain a native datepicker. I imagine you want to use this, so you'll need to source it in:
<script src="http://rawgit.com/eternicode/bootstrap-datepicker/release/js/bootstrap-datepicker.js"></script>
3.) setDefaults is a method of jquery-ui's datepicker not the bootstrap implementation I link above.
Updated fiddle.
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Sortable and droppable knockout list
I am using knockout to bind a UL. I am wanting to gives users the ability to drag and drop a LI and for my viewmodel to update with the reorder.
Drag and drop is working and I have the correct event working within my jquery but I am not sure how to make the update.
I have had a hunt around the documentation but cant find anything.
I've created a fiddle to make explaining what I am doing a little easier
Js Fiddle here
Any suggestions would be awesome!
Updated the jsfiddle link
I've never worked with Knockout and I don't have time to understand its intricacies right now, so this isn't a complete solution, but here's something to get you started. See below for links to some pages I found while searching that may help you complete the solution.
This is the part that I changed from your original fiddle:
var view_model = new ViewModel(initialData);
ko.applyBindings(view_model);
$(function() {
$( "#sortable" ).sortable({
revert: true,
stop: function(event, ui) { console.log("stop event")},
start : function ( event, ui ) {
ui.item.data( 'previous_index', ui.item.index() );
},
// start
update : function ( event, ui ) {
var question = view_model.questions.splice(
ui.item.data( 'previous_index' ), 1
)[0];
view_model.questions.splice( ui.item.index(), 0, question );
ui.item.removeData( 'previous_index' );
}
// update
});
});
References:
jQuery UI Sortable, how to determine current location and new location in update event?
get the start position of an item using the jquery ui sortable plugin
jQuery Sortable() with original position placeholder?
knockout + jqueryui draggable/droppable follow-up
Ryan Niemeyer has authored a Knockout plug-in for this purpose:
https://github.com/rniemeyer/knockout-sortable
Here is an updated blog entry:
http://www.knockmeout.net/2012/02/revisiting-dragging-dropping-and.html
I have a jQuery UI datepicker on my page and I set a defaultDate using the below code - but it keeps picking the month after the month I set! For example the below is showing as 1st December, not November!
var datePickDate = new Date(2011, 11, 01);
$("#datepicker").datepicker({
defaultDate: datePickDate,
onSelect: function(dateText, inst){
$("#datepicker_value").val(dateText);
}
});
Your code is Ok, except the fact that in javascript months are 0-based. So you should put 10 for month if you want November. Check it here
Our project using JSF1.2, Icefaces 1.8.2, jQuery UI component datepicker (veresion 1.8.14). Problem with IE7 (Firefox is fine). Problem will happen with following sequence: Select a date (for example, couple days befor doday). Note we have set year range from 1991 to 2012. Our business logic is print a document use that date (in code, called dateOfStudy) as title, once done, in the JSF back bean, I clear the calendar inputext date field to null. Now click datepicker icon again, the year corrtly shows 2011, select any previous month (for example go back to Auguest, 2011), problme happend right here: the year will change to 1991, can not keep at 2011.
The problem will not happen if I do not touch that date field (don't do clear, keep the old date). The problem will still appear even I just change the date font to other color via CSS (seems whenever I touch that field, datepicker will messed up). The problem will not happen if you click today once, or close datepicker, open again.
Seems the datepick need some initializtion after I cleared date?
I attached some code. I have trid method/option like setDate, onChangeMonthYear, beforShowDay, can not solve. Any help is appreciated !!
<script type="text/javascript">
var jq = jQuery.noConflict();
jq(document).ready(function() {
jq("[id$=fmv]").live('click', function() {
jq(this).datepicker( {
showOn : 'focus',
changeMonth : true,
changeYear : true,
dateFormat : 'mm/dd/yy',
yearRange : '-20:+1',
showButtonPanel : true,
closeText : 'Close'
}).focus();
});
});
</script>
<ice:inputText id="fmv"
style="background-image:url ('../../../jquery/images/calendar1.png');
background-repeat:no-repeat;background-position:right;"
value="#{pItem.dateOfStudy}"
validator="#{pItem.validate}"
partialSubmit="true"
name="fmv"
valueChangeListener="#{pItem.dateChangeListener}">
</ice:inputText>
When backbean clear or change input text in calendar inputText, I think that causes a focus event, and calendar confused under IE7. The reason I am using showOn focus is the code is in a table AJAX display area, so use calendar show on image button not work since the button image will not show when AJAX update comes back (the jQuery calendar will not get called), which force me to use showOn focus. I finally solved this year change problem by adding the following refresh calendar line after the final .focus():
jq(this).datepicker("setDate",jq("[id$=fmv]").datepicker("getDate"));
things working fine now. I am not sure how to make this call only when backbean clean the calendar date, but performance seems ok.