JS不在Rails上工作

时间:2013-04-30 16:46:28

标签: javascript jquery html ruby-on-rails include

我有一个名为“admin.js”的文件加载了一些JS文件。他们加载HTML但没有任何作用...我考虑到我有jquery错误,但我几乎不知道任何关于它。事实是,渲染的html代码几乎与rails输出相同,但是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>

Admin.js加载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结构中执行此操作并想要了解它为什么会发生...我没有错误消息,但手风琴和东西等控制器无法正常工作。

希望你们能帮忙。

0 个答案:

没有答案