igor-alexandrov / wiselinks

If Turbolinks are not enough for you. Wiselinks makes your application work faster.
MIT License
724 stars 89 forks source link

Different wiselinks behavior depending on the environment #79

Closed tab closed 10 years ago

tab commented 10 years ago

Hi,

in my Rails 3.2 application i use wiselinks gem for sorting collection. I have some filter that show part of my collection, example tasks closed or tasks with low priority.

Part of my application.js:

//= require jquery
//= require jquery_ujs
//= require wiselinks
//= require_tree .

$(document).ready ->
  window.wiselinks = new Wiselinks($('.js-wiselinks-content'))

One of the links in the filter:

<%= link_to link.title, link.path, :class => 'btn btn-link filter', :data => { :push => true } %>

In development environment everything works great, but in production i see that wiselinks work, content replaced and then I have page reloading.

If I use links with jquery-ujs, like this:

<%= link_to link.title, link.path, :class => 'btn btn-link filter', :remote => true, :data => { :push => true } %>

I have double content load with JS (jquery-ujs) and HTML (wiselinks)

Started GET "/tasks?state=closed" for 127.0.0.1 at 2014-07-07 09:23:49 +0700
Processing by TasksController#index as JS
...
Started GET "/tasks?state=closed" for 127.0.0.1 at 2014-07-07 09:23:49 +0700
Processing by TasksController#index as HTML
...

My development.rb:

App::Application.configure do
  config.cache_classes = false
  config.whiny_nils = true
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false
  config.action_mailer.raise_delivery_errors = false
  config.action_mailer.delivery_method = :letter_opener
  config.active_support.deprecation = :log
  config.action_dispatch.best_standards_support = :builtin
  config.active_record.mass_assignment_sanitizer = :strict
  config.active_record.auto_explain_threshold_in_seconds = 0.5
  config.assets.compress = false
  config.assets.debug = false
  config.assets.logger = false
end

My production.rb:

App::Application.configure do
  config.cache_classes = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = false
  config.assets.compress = true
  config.assets.compile = false
  config.assets.digest = true
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
end
igor-alexandrov commented 10 years ago

You don't need :remote => true param when working with Wiselinks.

tab commented 10 years ago

@igor-alexandrov thx! Everything works fine without :remote => true

igor-alexandrov commented 10 years ago

No problem.