Twitter bootstrap datepicker 在 rails 中不起作用 [英] Twitter bootstrap datepicker is not working in rails

查看:27
本文介绍了Twitter bootstrap datepicker 在 rails 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了 bootstrap-datepicker.js 并将其包含在我的应用程序 .js 文件中.它在视图中不起作用

 

<div id="dp5" class="input-append date" data-date-format="dd-mm-yyyy" data-date="12-02-2012"><input class="span2" type="dp5" readonly="" value="12-02-2012" size="16"><span class="附加组件"><i class="icon-th"></i></span>

它没有显示日期的日历.我哪里错了?

我的 application.js 文件是

//= 需要 jquery//= 需要 jquery_ujs//= 需要引导程序//= 需要引导程序日期选择器//= 需要选择器//= require_tree .$('#dp5').datepicker()

解决方案

//= require_self 添加到 application.js

这也包括它自己的文件内容.这必须明确完成.

还要保持 application.js 的格式

//= 需要 jquery//= 需要 jquery_ujs//= 需要引导程序//= 需要引导程序日期选择器//= 需要选择器//= require_tree .//= require_self$(函数(){$('#dp5').datepicker()});//不要在包含的文件之间保留存储空间.

我建议创建一个新的 js 文件并在其中添加内容,然后将其包含在 application.js 中

保留 application.js 作为索引文件

I download the bootstrap-datepicker.js and include it in my application .js file. It is not working in view

 <div class="well">
<div id="dp5" class="input-append date" data-date-format="dd-mm-yyyy" data-date="12-02-2012">
<input class="span2" type="dp5" readonly="" value="12-02-2012" size="16">
<span class="add-on">
<i class="icon-th"></i>
</span>
</div>

It is not displaying the calender for date. where m i wrong?

my application.js file is

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-datepicker

//= require picker
//= require_tree .

$('#dp5').datepicker()

解决方案

Add //= require_self to application.js

this includes its own file contents too. This has to be done explicitly.

also keep the application.js formatted

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-datepicker
//= require picker
//= require_tree .
//= require_self

$(function() {
   $('#dp5').datepicker()
 });

// Do not keep bank spaces between included files.

I would suggest to create a new js file and add contents in it and then include it in application.js

keep application.js as a index file

这篇关于Twitter bootstrap datepicker 在 rails 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆