Referencing a Bootstrap icon within jQuery datepicker buttonImage attribute?

半世苍凉 提交于 2019-12-05 10:31:35

For what you are doing, rather than messing with the buttonImage attribute, I recommend you just put the icon markup into the buttonText value

.value('ui.config', {
    date: {
        dateFormat : 'mm-dd-yy',
        minDate    : '+1d',
        showOn     : 'button',
        buttonText : '<i class="icon-calendar"></i>'
    }
})

I know this is a late reply, but I found this article which does the same thing and with ease:

http://jasenhk.wordpress.com/2013/03/09/jquery-datepicker-with-bootstrap-icon/

and jsFiddle from the same article: http://jsfiddle.net/jasenhk/B2txR/

The author suggests using the "for" attribute to match the id of the input control.

The fiddle has a simple appended input control:

<div class="form-horizontal">
    <div class="control-group">
        <label for="date-picker-2" class="control-label">B</label>
        <div class="controls">
            <div class="input-append">
                <input id="date-picker-2" type="text" class="date-picker" />
                <label for="date-picker-2" class="add-on"><i class="icon-calendar"></i>
                </label>
            </div>
        </div>
    </div>
</div>

And then we just need to call datepicker as:

$(".date-picker").datepicker();

You can arrange the icon in following way and than assign jquery to them.

jsfiddle Jsfiddle datepicker

<div data-date-format="dd-mm-yyyy" data-date="19-02-2013" id="datepick"class="input-append date">
<input type="text" readonly="" value="19-02-2013" size="16" class="span2">  
    <span class="add-on"><i class="icon-calendar"></i></span>

<div class="control-group">
<label class="control-label" for="inputDatepicker">Datepicker</label>
<div class="controls">
    <div class="input-prepend">
        <button class="btn" type="button" id="datepick"><i class="icon-calendar"></i>
        </button>
        <input class="span2" id="appendedInputButton" type="text">
    </div>
</div>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!