-
Notifications
You must be signed in to change notification settings - Fork 138
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
Compatibility with rails 5.1 #135
Comments
This gem seems to be abandonware now. |
No it isn't. Just don't have time right now to work on it. But hey @esb happy to accept pull requests though! |
I've just been battling a similar problem with Rails 5.1 and rails_ujs, so I'm hoping you can find the time to have a look at it as it would be nice to have the gem working with the current version of Rails. I've been trying to get the Control Form working, and it has been crashing in the rails_ujs handleRemote function. I switched back to the jquery_ujs version and it's working, so I don't know what the problem is. I think you'd have some grateful users, if you could find time to have a look at this. |
I haven't found a fix for this issue so I disabled remote loading: $(document).on("turbolinks:load", function() {
// Disable ajax remote loading of smart listing links
// See https://github.com/sology/smart_listing/issues/135
$(".smart-listing a").on("click", function(e) {
e.preventDefault();
Turbolinks.visit(this.href);
});
}); |
@mizinsky this doesn't work for me and that's what prompted me to create this issue. See above for a detailed explanation of the problem. |
@vinc
was when I haven't properly installed jquery-rails gem and didn't include:
in my application.js file, before .attr() is a jQuery function, and your error may appear due to this function (smart_listing.coffee.erb file):
rails-ujs don't provide jQuery, and that is why we need jquery-rails gem working properly. |
Yes, the first part of my first message describe the error when I don't use
|
Closing this issue doesn't solve the problem. There's a big misunderstanding here. jquery_ujs does not provide jQuery. It is merely the set of tools for UJS that rails needs that was written using jQuery. In Rails 5, this was re-written as rails_ujs and it doesn't have a dependency on jQuery. That being said, if you need jQuery under Rails 5, just include it via yarn and use rails_ujs for the UJS support. The issue here is that something breaks with smart_listing when using the rails_ujs code, and that it the problem. It means the code is not compatible with Rails 5. |
With Maybe I should produce a small test case to reproduce the problem. |
@esb SmartListing in its current state requires jQuery to operate. This means you need to use
|
For what it's worth, and know that I've only been looking into getting pagination to work as intended, I altered smart_listing.coffee.erb:4 to check only that element.href exists rather than that element.attr("href") exists:
And since I struggled to get $.rails.href to be defined properly, my application.js requires in order:
I have a lot more to look into (my search for gems supporting edit in place is what led me to SmartListing) so if I encounter and resolve other issues, I'll return here to see if the conversation is continuing! Thank you, @mizinsky for the gem, and everyone else for the discussion. |
Readme just got updated. |
Hey there, first of all thanks for this gem that allows us have lightweight controllers without logic dealing with sort, filter and pagination!
I'm using rails 5.1.4 on a project and I can't figure out the proper setup.
If I install
jquery
withyarn
(for bootstrap) and keep using//= require rails-ujs
the sort and pagination work but I get aTypeError: element.attr is not a function
when I click on a table header to sort (but it works), and rails stuff like confirm dialog stop working with the same error.If I install
jquery-ujs
withyarn
and replace//= require rails-ujs
with//= require jquery-ujs
I don't have the broken confirm dialog anymore in other part of my app but nothing related to smart_listing work. When I click to sort nothing happen (no errors) and when I click on the pagination the opacity of table is decreased but nothing happen (no errors).If I install the gem
jquery-rails
and replace//= require rails-ujs
with//= require jquery_ujs
it's the same thing.My understanding was that I needed to replace
//= require rails-ujs
with//= require jquery-ujs
(or//= require jquery_ujs
depending on where I get it from) to get smart_listing happy but that's not happening with rails 5.1.4.See #40 (comment) and maybe #85
The text was updated successfully, but these errors were encountered: