开发者

where to put my js for tipsy - jquery tooltip

So I've downloaded and included in my stylesheets and javascript files "tipsy.css" and "jquery.tipsy". I added the image "tipsy.gif" and modified it's path. I put in my application.js the following

$(window).load(function () {
   $('#example-1').tipsy();
});    
开发者_JAVA技巧

And I put this line in my view:

<a id='example-1' href='#' title='Hello World'>Hover over me</a>

When I hover over it no tipsy magic comes to work. Only the standard on hover title. What am I doing wrong here?

I am using ruby on rails and have included this in my stylesheets and js:

<%= stylesheet_link_tag 'application','tipsy'%>
<%= javascript_include_tag "application", "jquery", "jquery.tipsy"%>

I've tried many things from changing my window.load function and changing classes of my element and done a lot of googling but i just can't find the answer what is wrong here.

Any help would be greatly appreciated.


The tipsy source comes partitioned into the correct folders. You put the files in stylesheets/ into public/stylesheets, and so on. Then I would add javascript_include_tag "jquery.tipsy". Make sure to view the source to make sure that it's loading it, if not, then you have a name/path mismatch.

By the way, make sure you have installed the ujs handler for jQuery, otherwise, you're still using the rails-default of prototype, so that means that your references to the $ function are actually being routed to prototype and not jQuery.


Change:

<%= javascript_include_tag "application", "jquery", "jquery.tipsy"%>

to:

<%= javascript_include_tag "jquery", "jquery.tipsy", "application" %>

I don't know Ruby on rails and the javascript_include_tag but I assume you where loading application.js before jQuery and tipsy where available.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜