Search code examples
jqueryruby-on-railsedit-in-place

What is my document onLoad hander in Rails?


I want to use a plugin to make most of my models inline editable, but I don't understand the following:

To use it, include jquery.rest_in_place.js in your template and execute the following in your document’s onLoad handler:

jQuery(".rest_in_place").rest_in_place();

http://jan.varwig.org/projects/rest-in-place

Where do I place this?


Solution

  • They likely mean the jQuery document ready event.

    Inside your <head> section, place a $(document).ready(); like this.

    <head>
        <script type="text/javascript">
            jQuery(document).ready(function() {
                jQuery(".rest_in_place").rest_in_place();
            });
        </script>
    </head>
    

    Or

    <head>
          <script type="text/javascript">
              jQuery(function() {
                   jQuery(".rest_in_place").rest_in_place();
              });
          </script>
    </head>