[英]Rails 3.2 and Paloma gem
I'm facing a problem since yesterday. 从昨天开始我就遇到了问题。 I try to use Paloma gem (v5) to organize my javascript.
我尝试使用Paloma gem(v5)来组织我的JavaScript。 But I can't see any tutorial for this, in the current version.
但是,在当前版本中,我看不到任何教程。 That's not the problem, there is a good wiki about it.
那不是问题,有一个很好的维基。
But I can't use it, and I don't know why... 但是我不能使用它,我也不知道为什么...
Application.js Application.js
//= require jquery
//= require jquery_ujs
//= require jquery.ui.datepicker-fr
//= require jquery.ui.monthpicker
//= require jquery.timepicker
//= require jquery.validate
//= require jquery.remotipart
//= require redactor-rails
//= require magnific-popup
//= require selectize
//= require jquery-tablesorter
//= require jquery-tablesorter/jquery.tablesorter
//= require jquery-tablesorter/jquery.tablesorter.widgets
//= require Chart
//= require paloma
//= require_tree .
//= require bootstrap-multiselect
$(document).ready(function(){
Paloma.start();
});
My coffeeScript (it's compatible): 我的coffeScript(兼容):
console.log 'hello'
Paloma.controller 'Admin/RGrids', ->
show_users: ->
alert 'it works'
And my controller admin/r_grids_controller.rb 和我的控制器admin / r_grids_controller.rb
class Admin::RGridsController < AdminController
layout 'admin'
load_and_authorize_resource :r_grid
respond_to(:html, :js)
#show_users prints results in the retention grid for a USER
#@return [hash] rgrid_for_user
def show_users
rgrid_scoped = RGrid.only_askers
@show = RGridUtility.r_grid_vars(rgrid_scoped)
end
'Hello' is displayed in the console, so the script is loaded. 控制台中显示“ Hello”,因此脚本已加载。 I tried many things like remove :js in respond_to, or use different way to call the action.
我尝试了很多事情,例如response_to中的remove:js,或使用其他方式调用该操作。 Somebody can help me?
有人可以帮助我吗? :-)
:-)
Solved. 解决了。 Need to call Paloma.start() in my application.js with my function in r_grids.js inside the application.js
需要在application.js中使用r_grids.js中的函数在我的application.js中调用Paloma.start()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.