新手问题 rails 时间控件问题

76521 · July 16, 2013 · Last by 76521 replied at July 18, 2013 · 3396 hits

我已经把这个文件 WdatePicker.js 放到 assets 目录下了,但是我在页面上这样写 什么提示我 ReferenceError: WdatePicker is not defined,谁帮看一下啊?

你的问题应该是和 js 加载时间有关系 把 onclick 里面的代码抽出来放到 js 文件里面

$('.datepicker').click ->
  WdatePicker(...)

然后需要的 input 只用加 class datepicker 就行了 当然了我写的是 coffee 你还要注意 ready 的问题 如果是 ajax 页面要用 on 绑定

额,我看错了,script 标签有问题,用 rails 的 helper 吧

haml 里要这么写 = javascript_include_tag 'WdatePicker'

#3 楼 @zj0713001 thanks 已经解决了,我把加载 js 文件放在 index 页面上就可以了

#2 楼 @kikyous thanks 已经解决了,我把加载 js 文件放在 index 页面上就可以了

You need to Sign in before reply, if you don't have an account, please Sign up first.