我有一个名为“admin.js”的文件加载一些 JS 文件。他们在 HTML 中加载但没有任何效果......我考虑到我有 jquery 错误,但我对此几乎一无所知。事实是渲染的 html 代码几乎与从 rails 输出的相同,但 rails 不起作用。
导轨输出:
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/admin/breakpoints.js?body=1" type="text/javascript"></script>
<script src="/assets/admin/jquery-ui-1.10.1.custom.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admin/jquery.slimscroll.min.js?body=1" type="text/javascript"> </script>
<script src="/assets/admin/fullcalendar.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admin/bootstrap.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admin/jquery.blockui.js?body=1" type="text/javascript"></script>
<script src="/assets/admin/jquery.cookie.js?body=1" type="text/javascript"></script>
<script src="/assets/admin/jquery.flot.js?body=1" type="text/javascript"></script>
<script src="/assets/admin/jquery.flot.resize.js?body=1" type="text/javascript"> </script>
<script src="/assets/admin/jquery.gritter.min.js?body=1" type="text/javascript"> </script>
<script src="/assets/admin/jquery.uniform.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admin/date.js?body=1" type="text/javascript"></script>
<script src="/assets/admin/daterangepicker.js?body=1" type="text/javascript"></script>
<script src="/assets/admin.js?body=1" type="text/javascript"></script>
<script>
jQuery(document).ready(function() {
App.setPage("index"); // set current page
App.init(); // init the rest of plugins and elements
});
</script>
工作 HTML 输出:
<!-- BEGIN JAVASCRIPTS -->
<!-- Load javascripts at bottom, this will reduce page load time -->
<script src="assets/js/jquery-1.8.3.min.js"></script>
<!--[if lt IE 9]>
<script src="assets/js/excanvas.js"></script>
<script src="assets/js/respond.js"></script>
<![endif]-->
<script src="assets/breakpoints/breakpoints.js"></script>
<script src="assets/jquery-ui/jquery-ui-1.10.1.custom.min.js"></script>
<script src="assets/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<script src="assets/fullcalendar/fullcalendar/fullcalendar.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.blockui.js"></script>
<script src="assets/js/jquery.cookie.js"></script>
<script src="assets/flot/jquery.flot.js"></script>
<script src="assets/flot/jquery.flot.resize.js"></script>
<script type="text/javascript" src="assets/gritter/js/jquery.gritter.min.js"></script>
<script type="text/javascript" src="assets/uniform/jquery.uniform.min.js"></script>
<script type="text/javascript" src="assets/bootstrap-daterangepicker/date.js"></script>
<script type="text/javascript" src="assets/bootstrap-daterangepicker/daterangepicker.js"></script>
<script src="assets/js/app.js"></script>
<script>
jQuery(document).ready(function() {
App.setPage("index"); // set current page
App.init(); // init the rest of plugins and elements
});
</script>
加载 JS 的 Admin.js 文件(及其实际工作)
// This is a manifest file that'll be compiled into application, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, libjavascripts, vendorjavascripts,
// or vendorjavascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//= require jquery_ujs
//= require jquery
//= require admin/breakpoints
//= require admin/jquery-ui-1.10.1.custom.min
//= require admin/jquery.slimscroll.min
//= require admin/fullcalendar.min
//= require admin/bootstrap.min
//= require admin/jquery.blockui
//= require admin/jquery.cookie
//= require admin/jquery.flot
//= require admin/jquery.flot.resize
//= require admin/jquery.gritter.min
//= require admin/jquery.uniform.min
//= require admin/date
//= require admin/daterangepicker
和 admin.html.erb 文件
<!DOCTYPE html>
<html>
<head>
<title>title</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= csrf_meta_tags %>
</head>
<body class="fixed-top">
<%= yield %>
<%= javascript_include_tag "admin" %>
<script>
jQuery(document).ready(function() {
App.setPage("index"); // set current page
App.init(); // init the rest of plugins and element }
);
</script>
</body>
</html>
我已经尝试了很多选择。事实是,当我从原始 HTML 粘贴代码时,只是更改了我的 rails 应用程序资产的路径,它可以工作,但我想以正确的 rails 结构执行此操作,并想了解它发生的原因......我没有错误消息,但手风琴之类的控制器无法正常工作。
希望你们能帮忙。