开发者

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-i开发者_C百科n-place

Where do I place this?


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>


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜