diff options
Diffstat (limited to 'railties/guides/source')
-rw-r--r-- | railties/guides/source/action_view_overview.textile | 179 | ||||
-rw-r--r-- | railties/guides/source/layouts_and_rendering.textile | 6 |
2 files changed, 5 insertions, 180 deletions
diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile index 172932fdab..9e59383315 100644 --- a/railties/guides/source/action_view_overview.textile +++ b/railties/guides/source/action_view_overview.textile @@ -526,7 +526,7 @@ javascript_include_tag "common" # => <script type="text/javascript" src="/javascripts/common.js"></script> </ruby> -To include the Prototype and Scriptaculous JavaScript libraries in your application, pass +:defaults+ as the source. When using +:defaults+, if an +application.js+ file exists in your +public/javascripts+ directory, it will be included as well. +If the application does not use the asset pipeline, to include the jQuery JavaScript library in your application, pass +:defaults+ as the source. When using +:defaults+, if an +application.js+ file exists in your +public/javascripts+ directory, it will be included as well. <ruby> javascript_include_tag :defaults @@ -1301,7 +1301,7 @@ h4. JavaScriptHelper Provides functionality for working with JavaScript in your views. -Rails includes the Prototype JavaScript framework and the Scriptaculous JavaScript controls and visual effects library. If you wish to use these libraries and their helpers, make sure +<%= javascript_include_tag :defaults, :cache => true %>+ is in the HEAD section of your page. This function will include the necessary JavaScript files Rails generated in the +public/javascripts+ directory. +Rails includes by default the jQuery JavaScript library. If you wish to use these libraries and they are in your asset pipeline, or otherwise make sure +<%= javascript_include_tag :defaults, :cache => true %>+ is in the HEAD section of your page. This function will include the necessary JavaScript files Rails generated in the +public/javascripts+ directory. h5. button_to_function @@ -1402,16 +1402,6 @@ number_with_precision(111.2345) # => 111.235 number_with_precision(111.2345, 2) # => 111.23 </ruby> -h4. PrototypeHelper - -Prototype is a JavaScript library that provides DOM manipulation, Ajax functionality, and more traditional object-oriented facilities for JavaScript. This module provides a set of helpers to make it more convenient to call functions from Prototype using Rails, including functionality to call remote Rails methods (that is, making a background request to a Rails action) using Ajax. - -To be able to use these helpers, you must first include the Prototype JavaScript framework in the HEAD of the pages with Prototype functions. - -<ruby> -javascript_include_tag 'prototype' -</ruby> - h5. evaluate_remote_response Returns +eval(request.responseText)+ which is the JavaScript function that form_remote_tag can call in +:complete+ to evaluate a multiple update return document using +update_element_function+ calls. @@ -1508,171 +1498,6 @@ would generate: return false;" type="button" value="Create" /> </html> -h5. update_page - -Yields a JavaScriptGenerator and returns the generated JavaScript code. Use this to update multiple elements on a page in an Ajax response. - -<ruby> -update_page do |page| - page.hide 'spinner' -end -</ruby> - -h5. update_page_tag - -Works like update_page but wraps the generated JavaScript in a +script+ tag. Use this to include generated JavaScript in an ERB template. - -h4. PrototypeHelper::JavaScriptGenerator::GeneratorMethods - -JavaScriptGenerator generates blocks of JavaScript code that allow you to change the content and presentation of multiple DOM elements. Use this in your Ajax response bodies, either in a +script+ tag or as plain JavaScript sent with a Content-type of "text/javascript". - -h5(#push). << - -Writes raw JavaScript to the page. - -<ruby> -page << "alert('JavaScript with Prototype.');" -</ruby> - -h5(#at). [] - -Returns a element reference by finding it through it's id in the DOM. - -<ruby> -page['blank_slate'].show # => $('blank_slate').show(); -</ruby> - -h5. alert - -Displays an alert dialog with the given message. - -<ruby> -page.alert('This message is from Rails!') -</ruby> - -h5. assign - -Assigns the JavaScript variable the given value. - -<ruby> -page.assign 'tabulated_total', @total_from_cart -</ruby> - -h5. call - -Calls the JavaScript function, optionally with the given arguments. - -<ruby> -page.call 'Element.replace', 'my_element', "My content to replace with." -</ruby> - -h5. delay - -Executes the content of the block after a delay of the number of seconds provided. - -<ruby> -page.delay(20) do - page.visual_effect :fade, 'notice' -end -</ruby> - -h5. draggable - -Creates a script.aculo.us draggable element. See ActionView::Helpers::ScriptaculousHelper for more information. - -h5. drop_receiving - -Creates a script.aculo.us drop receiving element. See ActionView::Helpers::ScriptaculousHelper for more information. - -h5. hide - -Hides the visible DOM elements with the given ids. - -<ruby> -page.hide 'person_29', 'person_9', 'person_0' -</ruby> - -h5. insert_html - -Inserts HTML at the specified position relative to the DOM element identified by the given id. - -<ruby> -page.insert_html :bottom, 'my_list', '<li>Last item</li>' -</ruby> - -h5. literal - -Returns an object whose to_json evaluates to the code provided. Use this to pass a literal JavaScript expression as an argument to another JavaScriptGenerator method. - -h5. redirect_to - -Redirects the browser to the given location using JavaScript, in the same form as +url_for+. - -<ruby> -page.redirect_to(:controller => 'accounts', :action => 'new') -</ruby> - -h5. remove - -Removes the DOM elements with the given ids from the page. - -<ruby> -page.remove 'person_23', 'person_9', 'person_2' -</ruby> - -h5. replace - -Replaces the "outer HTML" (i.e., the entire element, not just its contents) of the DOM element with the given id. - -<ruby> -page.replace 'person-45', :partial => 'person', :object => @person -</ruby> - -h5. replace_html - -Replaces the inner HTML of the DOM element with the given id. - -<ruby> -page.replace_html 'person-45', :partial => 'person', :object => @person -</ruby> - -h5(#prototype-select). select - -Returns a collection reference by finding it through a CSS pattern in the DOM. - -<ruby> -page.select('p.welcome b').first.hide # => $$('p.welcome b').first().hide(); -</ruby> - -h5. show - -Shows hidden DOM elements with the given ids. - -<ruby> -page.show 'person_6', 'person_13', 'person_223' -</ruby> - -h5. sortable - -Creates a script.aculo.us sortable element. Useful to recreate sortable elements after items get added or deleted. See ActionView::Helpers::ScriptaculousHelper for more information. - -h5. toggle - -Toggles the visibility of the DOM elements with the given ids. Example: - -<ruby> -page.toggle 'person_14', 'person_12', 'person_23' # Hides the elements -page.toggle 'person_14', 'person_12', 'person_23' # Shows the previously hidden elements -</ruby> - -h5. visual_effect - -Starts a script.aculo.us visual effect. See ActionView::Helpers::ScriptaculousHelper for more information. - - -TODO start from RecordIdentificationHelper - - h3. Localized Views Action View has the ability render different templates depending on the current locale. diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile index 620df970dc..d67668df91 100644 --- a/railties/guides/source/layouts_and_rendering.textile +++ b/railties/guides/source/layouts_and_rendering.textile @@ -695,13 +695,13 @@ To include +http://example.com/main.js+: <%= javascript_include_tag "http://example.com/main.js" %> </erb> -The +:defaults+ option loads jQuery by default: +If the application does not use the asset pipeline, the +:defaults+ option loads jQuery by default: <erb> <%= javascript_include_tag :defaults %> </erb> -If the application was generated with "-j prototype" <tt>:defaults</tt> loads Prototype and Scriptaculous. And you can in any case override the expansion in <tt>config/application.rb</tt>: +And you can in any case override the expansion in <tt>config/application.rb</tt>: <ruby> config.action_view.javascript_expansions[:defaults] = %w(foo.js bar.js) @@ -709,7 +709,7 @@ config.action_view.javascript_expansions[:defaults] = %w(foo.js bar.js) When using <tt>:defaults</tt>, if an <tt>application.js</tt> file exists in <tt>public/javascripts</tt> it will be included as well at then end. -The +:all+ option loads every JavaScript file in +public/javascripts+: +Also, the +:all+ option loads every JavaScript file in +public/javascripts+: <erb> <%= javascript_include_tag :all %> |