BootStrap DatePicker NoConflict [英] BootStrap DatePicker NoConflict
问题描述
根据文档: https://github.com/eternicode/bootstrap-datepicker#no-conflict
bootstrap datepicker现在可以使用noConflict:
bootstrap datepicker can use noConflict now:
var datepicker = $.fn.datepicker.noConflict();
$.fn.bootstrapDP = datepicker; // give $().bootstrapDP the bootstrap-datepicker functionality
它表示给$()。 bootstrapDP引导日期戳功能,这是什么意思?这是否意味着我可以使用 $(#object)。bootstrapDP()
而不是 $(#object)。datepicker() / code>?
It said "give $().bootstrapDP the bootstrap-datepicker functionality", what does this mean? Does it means I can use $("#object").bootstrapDP()
instead of $("#object").datepicker()
?
我已经在firefox中尝试过(只是为了测试,实际上并不冲突到任何js),但是日期选择不显示,没有错误出现(从firebug),这很奇怪。
I have tried it in firefox (just for test, actually not conflict to any js), but the "date-choose" does not show, and no error appear (from firebug), that is weird.
以下是我的代码:
<div class="input-append date" id="dp3" data-date-format="dd-mm-yyyy">
<input class="span2" size="16" type="text" readonly><span class="add-on"><i class="icon-th"></i></span>
</div>
JS
JS
<script>
$(function(){
var datepicker = $.fn.datepicker.noConflict;
$.fn.bootstrapDP = datepicker;
$("#dp3").bootstrapDP();
});
</script>
当我用 $(#dp3)替换脚本时datepicker ()
,将显示日期选择。
任何人都可以告诉我如何使用noConflict来引导datepicker?
When I replace the script with $("#dp3").datepicker()
, the "date-choose" will show.
Can anyone tell me how to use noConflict to bootstrap datepicker?
推荐答案
你错过了 noConflict
函数,写它们是很好的。
You miss the paren on the noConflict
function, writing them is working well.
代码:
$(function(){
var datepicker = $.fn.datepicker.noConflict();
$.fn.bootstrapDP = datepicker;
$("#dp3").bootstrapDP();
});
工作演示: http://jsfiddle.net/IrvinDominin/faxyz/
这篇关于BootStrap DatePicker NoConflict的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!