我有一个div.scroll_fixed与以下CSS
.scroll_fixed {
position:absolute
top:210px
}
.scroll_fixed.fixed {
position:fixed;
top:0;
}
Run Code Online (Sandbox Code Playgroud)
当div到达页面顶部时,我正在使用以下jQuery代码来设置.fixed类.
var top = $('.scroll_fixed').offset().top - parseFloat($('.scroll_fixed').css('margin-top').replace(/auto/, 0));
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the form
if (y >= top) {
// if so, ad the fixed class
$('.scroll_fixed').addClass('fixed');
} else {
// otherwise remove it
$('.scroll_fixed').removeClass('fixed');
}
});
Run Code Online (Sandbox Code Playgroud)
这适用于垂直滚动固定.但是对于一个小的浏览器窗口,水平滚动会导致与此固定div右侧的内容发生冲突.
我希望div能够水平滚动内容.
任何人都可以指出我正确的方向.还在用JS/JQuery弄湿我的脚.
我基本上希望它像本例中的第二个框一样工作.
我正在使用meta_search对表中的列进行排序.我的一个表列是特定模型的相关记录的计数.
基本上是这样的:
class Shop < ActiveRecord::Base
has_many :inventory_records
def current_inventory_count
inventory_records.where(:current => true).count
end
end
class InventoryRecord < ActiveRecord::Base
belongs_to :shop
#has a "current" boolean on this which I want to filter by as well
end
Run Code Online (Sandbox Code Playgroud)
在我的Shop #index视图中,我有一个表格列出了每个商店的current_inventory_count.无论如何使用meta_search按此计数订购商店?
我无法使用current_inventory_count方法,因为meta_search只能使用返回ActiveRecord :: Relation类型的自定义方法.
我能想到这样做的唯一方法是做一些自定义SQL,其中包括"虚拟"列中的计数,并按此列进行排序.我不确定这是否可能.
有任何想法吗?
我正在使用Rails 3.0.3和最新的meta_search.
我的团队不断在我们的heroku控制台上获取New Relic日志消息.当您处理较长的命令时,这会非常烦人并导致问题,并且会通过您的命令打印出一批新的遗留日志消息.
其他人有这个吗?关于如何补救的任何方向?
我正在使用Ryan Bates nested_form gem.我希望能够控制它列出嵌套字段的顺序.我有一个可用的default_scope,但我需要根据场景对此进行更多控制.
理想情况下
# In controller action
@nesties = Nesty.order("name desc")
# In view
# If @nesties defined the following line would respect the @nesties ordering
f.fields_for :nesties do |nestie-form|
Run Code Online (Sandbox Code Playgroud)
现在它将遵循default_scope排序,但我找不到任何其他方法来控制排序.
我有一个User和一个Rep模型
devise_for :users, :controllers => {:registrations => 'user_registration'}
devise_for :reps
Run Code Online (Sandbox Code Playgroud)
我跑了
rails generate devise:views reps
Run Code Online (Sandbox Code Playgroud)
自定义视图显示在app/views/reps中
但是rep路径仍然使用内置的设计视图
渲染〜/ .rvm /宝石/红宝石1.9.2-P290 /宝石/设计-1.4.9 /应用/视图/设计/注册/ edit.html.erb
而不是生成的代表视图.
activerecord ×1
css ×1
devise ×1
fixed ×1
heroku ×1
jquery ×1
meta-search ×1
nested-forms ×1
newrelic ×1