我在rails 4.2.5上使用ruby并使用filterrific和will_paginate 3.0.6 gems。但是,当我选择任何复选框时,我的javascript被破坏而无效。
我的js文件
ArrayList
});
我的index.html.haml对我的产品进行排序
ArrayList<String > cp= new ArrayList<>();
cp.add(super.getStoreLocation());
cp.add(super.getEmployeeId());
cp.add("$3500");
cp.add(timeStamp()); // and so on. No need to define the size at early.
my products_controller.rb
$('.spin span:last-child').click(function(){
inputValue = parseInt($(this).parent().find($('.custom-input')).val());
inputValue += 1
$(this).parent().find($('.custom-input')).val(inputValue);
unitPrice = parseFloat($(this).closest('.product').find('.unit-price span').text().substring(3));
subTotal = parseFloat(inputValue * unitPrice).toFixed(2);
$(this).closest('.product').find('.total-price span').text(subTotal);
和我的distributor_product.rb模型
.flex-container.products.wrapper.no-flex
.flex-container.relative
= form_for_filterrific @filterrific do |f|
.flex-item.sort-items<
Sort for
.select-style
= f.select(:sorted_by, @filterrific.select_options[:sorted_by], id: 'sort-select', include_blank: 'Seleccionar')
.filter-items.panel.panel-body
%h3.no-margin Mostrar por
%h4<
Type
%i.fa.fa-chevron-down>
%i.fa.fa-chevron-up
%ul
- @filterrific.select_options[:with_brand].each do |brand|
%li
= f.check_box :with_brand, { multiple: true, id: "filterrific_#{brand.name}", class: 'custom-checkbox' }, brand.id
= f.label brand.name, class: 'custom-label'
%h4<
Category
%i.fa.fa-chevron-down>
%i.fa.fa-chevron-up
所以,当我选择了一个复选框时,我不知道为什么我的js不工作,我需要重新加载页面:/,thx为响应。
答案 0 :(得分:3)
原因可能在Gemfile
。尝试将其添加到gem 'jquery-turbolinks'
:
bundle install
然后运行application.js
并按此顺序将其添加到//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//
// ... your other scripts here ...
//
//= require turbolinks
:
Traceback (most recent call last):
File "C:/Users/chianh/Desktop/Reliability Py Scripts/MedianRanks_Solver_Rev0.py", line 48, in <module>
slope, intercept, r_value, p_value, std_err = stats.linregress(data, median_rank)
File "C:\Users\chianh\AppData\Local\Programs\Python\Python35-32\lib\site-packages\scipy\stats\_stats_mstats_common.py", line 81, in linregress
r_den = np.sqrt(ssxm * ssym)
AttributeError: 'Float' object has no attribute 'sqrt'
重新启动服务器,然后重试。希望这会对你有所帮助。