There are lots of different answers to this question.   When you're
fooling around, the simplest is often just to put a script tag in the
middle of your code:

    <div id="foo">Foo</div>
    <script type="text/javascript">
        $(document).ready(function() {
           $('#foo').tooltip();
        });
     </script>

But eventually you'll want to put your javascript in a separate file
somewhere in /app/assets/javascripts/application/  or
/app/assets/javascripts/front/

Your file should look something like:

var myCode = function() {
   $('#mypage #foo').tooltip();
};
$(document).ready(myCode);
$(window).bind('page:change', myCode);

Structuring it this way ensures that your code works whether or not
you turn on the bottom-load-javascript option or add the turbolinks
gem.

Note that myCode runs on every page.   That's why I scoped the
selector with #mypage.   There are ways to have page specific
javascript, but you're better off with the same javascript for every
page so that you can take full advantage of the asset pipeline and
turbolinks.

Bryan

On Tue, Jan 29, 2013 at 5:49 PM, [email protected]
<[email protected]> wrote:
> I would like to use the Bootstrap tooltips, as in
>
>   http://twitter.github.com/bootstrap/javascript.html#tooltips
>
> It looks like the tooltip is enabled by some Javascript, like this (from the
> bootstrap site above):
>
>   Trigger the tooltip via JavaScript:
>
>       $('#example').tooltip(options)
>
> But, in Hobo, I don't see where to place that Javascript. Any help?
>
> I am new to Javascript and I know this is a very basic question. Thanks!
>
> Paul
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/hobousers?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to