Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Reload Only Works Once? #330

Open
BagpipesJohnson opened this issue Oct 7, 2016 · 3 comments
Open

Auto Reload Only Works Once? #330

BagpipesJohnson opened this issue Oct 7, 2016 · 3 comments

Comments

@BagpipesJohnson
Copy link

I am hoping that I am not barking up the wrong tree--

I am working with a SIMPLE wice grid to filter descriptions (Which are strings)

The first time I change the filter, the page reloads and everything is alright--after that point, I can change the drop down and nothing happens. I click on reset filter and nothing happens either. I have checked and see that JQuery is indeed loaded along with all of wice grid js files.

I have attached the files I would imagine you would need:

View:

'<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">

<%= grid(@conversation_grid, show_filters: :always) do |g|
  g.column name:  'Description', attribute: 'description', auto_reload: true, custom_filter: :auto
  end -%>

<%= link_to 'New Conversation', new_conversation_path, {class: "btn btn-info"} %>`

Controller:

`def index
    @conversations = Conversation.all
    @conversation_grid = initialize_grid(Conversation)
    @current_user  = UserUtils.get_current_employee_observer(session)
  end`

Application.js:

`// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory 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
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require bootstrap-sprockets
//= require bootstrap
//= require jquery_ujs
//= require jquery-ui
//= require wice_grid
//= require jquery-ui/datepicker
//= require_tree .
//= require turbolinks
//= require Chart.bundle
//= require chartkick
//= require_tree .

function remove_fields(link, row) {
  $(link).prev("input[type=hidden]").val("1");
  $(row).hide()
}

function add_fields(link, association, content, table) {
  var new_id = new Date().getTime();
  var regexp = new RegExp("new_" + association, "g")
  var row = $('#' + table + " tr:nth-last-child(1)")
  row.before(content.replace(regexp, new_id));


}`

Many thanks

@BagpipesJohnson
Copy link
Author

BagpipesJohnson commented Oct 7, 2016

I also turned off auto reload and tried to reload by clicking the filter item and it is unresponsive. Also unable to show/hide filters when changing "Filter Always" to "When Filtered"

@cedricdeschenes
Copy link

I know this issue is kinda old and I won't really provide a solution, but it seems like the problem is with Turbolinks, if you turn it off, you should be able to use the filters again.

I hope this might help you!

@patricklindsay
Copy link
Contributor

This is fixed in master but a release hasn't been cut for it.

As a work around you can call initWiceGrid() yourself;

document.addEventListener("turbolinks:load", function() {
  initWiceGrid();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants