QuestionHub gathers questions from leading sites, helping you to quickly and effectively find answers.

We’ve Updated

QuestionHub 2.0 has been launched!
Click here to read about our changes!

About Us

QuestionHub is a one-stop shop for finding all things Q&A online. Use QuestionHub as a starting point when searching for answers online!

Home > Javascript > Use JQuery UI Datepicker with Icons from Jquery UI Theme

Question:

Use JQuery UI Datepicker with Icons from Jquery UI Theme
Use JQuery UI Datepicker with Icons from Jquery UI Theme


I have a datepicker control setup specific image, i.e.:
<script type="text/javascript">
$(document).ready(function() {
$("#DateFrom").datepicker({ showOn: 'button', buttonImageOnly: true, buttonImage: 'images/ui-icon-calendar.png' });
});
</script>




To display an icon from the icon set you use something like:

<span class="ui-icon ui-icon-calendar"></span>


Is there an easy to integrate the two or do I just need to hack out using the JQuery UI, I am also using the a bunch of default icons.

The DatePicker allows for specifying a that I want to use JQuery UI themes which provide
the styles/images manually?

http://stackoverflow.com/questions/802379/use-jquery-ui-datepicker-wit h-icons-from-jquery-ui-theme



See Related Questions There are 5 answers to this question.

Answers:



I'm afraid you'll have to do that manually



...instead of...

$(document).ready(function() {
// your code here
});
. By default, the Datepicker plugin uses the specified buttonImage



By the way, you might want to use following HTML to insert the:

<img title="..." alt="..." src="images/ui-icon-calendar.png" class="ui-datepicker-trigger">
...

$(function() {
// your code here
});




I got it working by doing inserts next to your input ellipses in the text, so I remove that as

Just modifies the button that it for the calendar. By default they throw three this
 $("#DateFrom").datepicker({ showOn: 'button'}).next('button').text('').button({icons:{primary : 'ui-icon-calendar'}});
well.



@Loktar: that worked well. Thanks.



I suggest putting the image into

Like

date_picker_example

This removes the need of doing the input
input.date_picker {
text-align: center;
background-image: url("images/ui-icon-calendar.png");
background-position: right center;
background-repeat: no-repeat;
padding-right: 18px;
width: 78px;
}
a trigger manually



http://jqueryui.com/demos/datepicker/#icon-trigger

A very good example with the
sample code is provided.



Borrowing from and extending Loktar's answer, you could try something like, clicking the icon triggers the this, note I have only tested



Note that in this example, date-picker-button-hidden are my own classes, since I don't like styling the jQuery CSS

This is effectively placing a regular button. The button is completely see on top of the icon and date-picker-icon-through / opaque (via the CSS), however because it is still jQuery span icon behind the classes directly. Apply the following CSS:

span.date-picker-icon
{
display: inline-block;
z-index: -1;
position: relative;
left: -16px;
}

button.date-picker-button-hidden
{
opacity: 0.0;
filter: alpha(opacity=0);
height: 16px;
width: 16px;
margin: 0;
padding: 0;
}
this in FF10, but I can't see why it wouldn't work in other browsers.
$('.date-picker').datepicker({showOn: 'button'})
.next('button').addClass('date-picker-button-hidden')
.after($('<span/>')
.addClass('ui-icon').addClass('ui-icon-calendar').addClass('date-picker-icon'));
button click event.


Related Questions

Jquery datepicker problem help!!!!!? Jquery datepicker problem help!!!!!? i want to use JQuery project. Actually i want to add libraries for my web development Jquery's datepicker ( is a calender) to my site. The...

Programming & Design - 1,137 days ago - 0 Answers

Jquery datepicker - Getting runtime error in IE 6 and 7? Jquery datepicker - Getting runtime error in IE inclusion of files:- and following is the content 6 and 7? Following is the sequence of of calendar.js file:- ==...

Programming & Design - 1,087 days ago - 1 Answer

jquery disable anchor link and run jquery plugin instead? jquery disable anchor link and run run a jquery plugin from if I try this : Click here I get an an anchor Click here but jquery plugin instead? I already know how to error...

Programming & Design - 1,104 days ago - 1 Answer

How do I reference or access the id of a dropped draggable when using jquery and jquery UI? I have successfully got drag and the dragged element has not droppable area, however accessing the Id of webpage and have no trouble accessing the Id of the drop to work on my...

Programming & Design - 1,311 days ago - 0 Answers

jquery datepicker: alert when certain days are clicked on the jquery datepicker i have a certain dates that to block those dates from selecting, how would i do that come from database and want are clicked on the jquery? like Alert when certain days datep...

Asp.net - 736 days ago - 2 Answers

Why jQuery UI datepicker can't works in jQuery dialog modal? I want to use jQuery UI the normal document text inputs and i got my cal dialog modal. In fact, I can call datepicker in text inputs. This one is in a datepicker in one of my...

Jquery - 837 days ago - 0 Answers

jQuery Datepicker - Programatically Limit Second Datepicker I've recently been using the following my 2nd Date picker (end date) so that it does not precede the date of the piece of code to limit 1st Date picker. $("#datepicker").date...

Jquery - 757 days ago - 1 Answer

 
 
QuestionHub gathers questions from leading sites , helping you to quickly and effectively find answers.