What value should I be using for the jQuery datepicker buttonImage
attribute?
我应该为jQuery datepicker buttonImage属性使用什么值?
I would like to use the Bootstrap calendar icon with the jQuery datepicker. I can use the icon image in the html page when referenced like this:
我想使用带有jQuery datepicker的Bootstrap日历图标。当像这样引用时,我可以在html页面中使用图标图像:
<i class=icon-calendar></i>
When I use the angular-ui wrapper ui-date
to wrap the jQuery datepicker:
当我使用angular-ui包装器ui-date来包装jQuery datepicker时:
<div class="control-group">
<label class="control-label" for="startDate">Start Date</label>
<div class="controls">
<input class="span2" id="startDate" type="text"
data-ng-model="formModel.startDate"
data-ui-date="formModel.datePickerOptions"
data-ng-change="formModel.setAdjustmentDate()"
required >
</div>
</div>
with the controller defining the datepicker options as:
控制器将datepicker选项定义为:
formModel.datePickerOptions = {
dateFormat: 'yy-M-dd'
,changeMonth: true
,changeYear: true
,buttonImage: '<i class=icon-calendar></i>'
,buttonImageOnly: true
,showOn: "button"
};
What value should I actually be inserting for the buttonImage?
我应该为buttonImage插入什么值?
The datepicker is expecting an image url something like this { buttonImage: "/images/datepicker.gif" }
.
datepicker期待一个像这样的图像URL {buttonImage:“/ images / datepicker.gif”}。
3 个解决方案
#1
7
For what you are doing, rather than messing with the buttonImage attribute, I recommend you just put the icon markup into the buttonText value
对于你正在做的事,而不是搞乱buttonImage属性,我建议你只需将图标标记放入buttonText值
.value('ui.config', {
date: {
dateFormat : 'mm-dd-yy',
minDate : '+1d',
showOn : 'button',
buttonText : '<i class="icon-calendar"></i>'
}
})
#2
8
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/
和来自同一篇文章的jsFiddle:http://jsfiddle.net/jasenhk/B2txR/
The author suggests using the "for" attribute to match the id of the input control.
作者建议使用“for”属性来匹配输入控件的id。
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:
然后我们只需要将datepicker称为:
$(".date-picker").datepicker();
#3
0
You can arrange the icon in following way and than assign jquery to them.
您可以按照以下方式排列图标,然后将jquery分配给它们。
jsfiddle Jsfiddle datepicker
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>
#1
7
For what you are doing, rather than messing with the buttonImage attribute, I recommend you just put the icon markup into the buttonText value
对于你正在做的事,而不是搞乱buttonImage属性,我建议你只需将图标标记放入buttonText值
.value('ui.config', {
date: {
dateFormat : 'mm-dd-yy',
minDate : '+1d',
showOn : 'button',
buttonText : '<i class="icon-calendar"></i>'
}
})
#2
8
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/
和来自同一篇文章的jsFiddle:http://jsfiddle.net/jasenhk/B2txR/
The author suggests using the "for" attribute to match the id of the input control.
作者建议使用“for”属性来匹配输入控件的id。
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:
然后我们只需要将datepicker称为:
$(".date-picker").datepicker();
#3
0
You can arrange the icon in following way and than assign jquery to them.
您可以按照以下方式排列图标,然后将jquery分配给它们。
jsfiddle Jsfiddle datepicker
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>