Plugins - Simple Ujs
Add to favorites
Simple-Ujs is a plugin that turns all of your view into Unobstrusive Javascripts views.
You don’t need to learn any new syntax or a whole bunch of new helpers, you have just to call 1 helper (<%= flush_ujs_handlers_list %>) at the bottom of your master templates as close to the closing tag.
You don’t need to learn any new syntax or a whole bunch of new helpers, you have just to call 1 helper (<%= flush_ujs_handlers_list %>) at the bottom of your master templates as close to the closing tag.
flush_ujs_handlers_list(path = {}, session_id = nil) - ‘path’
- is the url path to the controller/action that will serve the javascript stored in the session with id of session_id.
The default path is /javascripts/ujs_handler and you can pass either a Hash or a String
- is the url path to the controller/action that will serve the javascript stored in the session with id of session_id.
- ‘Session_id’
- is the name of the session that will store the javascript code. The default session name is ‘ujs_script’
When you install this plugin it will automatically copy the file from /lib/simple_ujs/javascripts_controller.rb into your controllers folder.
(If that doesn’t happen from RAILS_ROOT runruby vendor/plugins/simple_ujs/install.rb)
There is a global settingSimpleUjs::Base.use_ujsthat can be set to either true or false to activate or deactivate the SimpleUjs plugin.
The SimpleUjs plugin also moves all of your javascript includes called with the javascript_include_tag method to the bottom of the page right before the call to /javascripts/ujs_handler. I do this because I strongly agree with Douglas Crockford. I can be convinced to make it user-choice though if somebody has reason.
The bottom of the page is the best place to insert javascript includes from a page load and performance perspective.
This plugin is for people like me that are sometimes lazy and believe that the best possible setting for any tool should always be the default one.
to install
ruby script/plugin installhttp://simple-ujs.googlecode.com/svn/simple_ujs/
- is the name of the session that will store the javascript code. The default session name is ‘ujs_script’
http://jroller.com/page/dscataglini
http://simple-ujs.googlecode.com/svn/simple_ujs/
Rails' (MIT)
View Extensions
