到目前为止,这是行不通的。当我单击将jquery-datetimepicker安装为节点模块的表单中的字段时,没有任何反应
application.js:
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
require("@rails/ujs").start()
require("jquery")
require("jquery-datetimepicker")
//require("bootstrap-datepicker")
require("js.cookie")
require("turbolinks").start()
require("@rails/activestorage").start()
require.context('../images', true)
require.context('../stylesheets/fonts', true)
require("trix")
require("@rails/actiontext")
import "bootstrap"
// import "blueimp-gallery"
import "../stylesheets/application"
document.addEventListener("turbolinks:load", () => {
$('[data-toggle="tooltip"]').tooltip()
$('[data-toggle="popover"]').popover()
})
import JQuery from 'jquery';
window.jQuery = $;
window.$ = $;
// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
_press_release_form.js:
$(document).ready(function () {
$('#showdate').datepicker();
$('#showtime').timepicker();
})
答案 0 :(得分:0)
您正在使用require("jquery-datetimepicker")
应改为$('#showdate').datetimepicker()
document.addEventListener("turbolinks:load", () => {
$('#showdate').datetimepicker()
})