Allow manual initialization of jQuery UJS, if jQuery is not exposed to global namespace#482
Conversation
|
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @lucasmazza (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
6364084 to
95a7b38
Compare
8789109 to
267b70d
Compare
|
@rails-bot @lucasmazza Anyone? |
|
This sure would be nice to see merged. |
|
@wkirby Agree. It would be nice to hear any human feedback here, but seems like the project is kind of abandoned. |
|
@lucasmazza Can you please leave any feedback on this? |
|
Up? Guys, anybody? |
This simple fix just exports initialization function as a module, if there is no window.jQuery. In this case you can use it like that: $ = require 'jquery' jqueryUjsInit = require 'jquery-ujs' jqueryUjsInit($) Reference: rails/jquery-ujs#482 Source: https://github.com/rails/jquery-ujs/blob/master/src/rails.js
This simple fix just exports initialization function as a module, if there is no window.jQuery. In this case you can use it like that: $ = require 'jquery' jqueryUjsInit = require 'jquery-ujs' jqueryUjsInit($) Reference: rails/jquery-ujs#482
Problem
When you are using jQuery as a common js module, you try not to export it to window and require it manually only when you need it. But current implementation of jquery-ujs expects that jQuery is accessible in a global namespace.
Solution
This simple fix just exports initialization function as a module, if there is no
window.jQuery.In this case you can use it like that:
If there is a global jQuery, then requiring
jquery-ujswill be just enough:So, this change should be completely backward compatible. Just let me know, if I need to add tests here, or suggest your concerns, I'd be really glad to help pushing this fix forward.
upd: I tried to use original indentation, so it will be easier to inspect the diff.