Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Datepicker with FontAwesome Button?

I'm building a site with Foundation, and I have the FontAwesome icons installed. I'm trying to set up a form where a user can click on an input or a button to see the jQuery datepicker. I'd like to be able to use the FontAwesome icon in the button. But I can't seem to get the button to trigger the datepicker.

EDIT:

I kind of got it working, but I still can't figure out how to implement the FontAwesome icon. I have this in my HTML:

  <div class="row">
    <div class="large-3 columns">
        <label>Departure Date</label>
        <div class="row date collapse">
        <div class="small-9 columns"><input class="small-9 columns" placeholder="Choose Date" type="text" name="date" id="date"></div>
        </div>
    </div>
  </div>

And this in my JS:

$(function() {
    $( "#date" ).datepicker({
      showOn: "both", 
      buttonImage: "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
      buttonText: "THIS IS A BUTTON",
      buttonImageOnly: true
    });
  });

Where do I put the icon? Can I somehow put it in the buttonText argument?

like image 963
mcography Avatar asked Jun 03 '14 15:06

mcography


Video Answer


1 Answers

Add

buttonText: "<i class='fa fa-calendar'></i>"

and add CSS:

.ui-datepicker-trigger{
    border:none;
    background:none;
 }

refer JSFiddler Here.

like image 115
Ankit Sharma Avatar answered Oct 26 '22 03:10

Ankit Sharma