views:

3211

answers:

3

I have a datepicker control setup using the JQuery UI, I am also using the JQuery UI themes which provide a bunch of default icons that I want to use.

The DatePicker allows for specifying a 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 the styles/images manually?

+5  A: 

I'm afraid you'll have to do that manually. By default, the Datepicker plugin uses the following HTML to insert the specified buttonImage:

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

By the way, you might want to use...

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

...instead of...

$(document).ready(function() {
 // your code here
});
Mathias Bynens
Why would use use "$(function() {" instead of "$(document).ready(function() {"?
Thierry-Dimitri Roy
1) Because it's shorter. 2) Because it's easier to remember. 3) Because it does exactly the same thing, since it's an alias for `$(document).ready(function() { ... }`.
Mathias Bynens
+1 on your comment for explaining it........
Night Shade
Assuming you're not working in an old version, "$(function(){})" isn't available in all versions ;)
jamiebarrow
+1  A: 

I got it working by doing this

 $("#DateFrom").datepicker({ showOn: 'button'}).next('button').text('').button({icons:{primary : 'ui-icon-calendar'}});

Just modifies the button that it inserts next to your input for the calendar. By default they throw three ellipses in the text, so I remove that as well.

Loktar
A: 

@Loktar: that worked well. Thanks.

B Shelton