views:

25

answers:

2

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?

+3  A: 

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>
Marko
JavaScript runs without `<script>` tags now? :)
Nick Craver
Better keep the JavaScript code separate from HTML, in other words include a .js file instead of putting it in <HEAD>.
Adam Byrtek
Absolutely :) and `<head>` should be **lowercase**. Stick to the standard dude :p
Marko
@Nick - it was merely a case of `spot-the-error`. Noone noticed until you came along, so it worked :p
Marko
A: 

The author probably meant the jQuery ready handler which gets executed when the DOM (hierarchical structure of the document) is fully loaded.

Your JavaScript code should look as follows

$(document).ready(function() {
    $(".rest_in_place").rest_in_place();
});

Note that $ is a synonym for jQuery (unless you explicitly enable the compatibility mode).

Adam Byrtek