Elliot
Elliot

Reputation: 13835

Ajax page load in rails 3 is breaking other javascript functions..?

So I'm using http://code.drewwilson.com/entry/tiptip-jquery-plugin for tool tips in my app.

When a page loads, it works great. If I load a new page through ajax, the tool tipz on the new page simply don't show up.

Any ideas for what could be breaking something like this?

Upvotes: 0

Views: 447

Answers (2)

mu is too short
mu is too short

Reputation: 434645

When you say this:

$(".someClass").tipTip();

To bind the tooltips to some elements, that executes immediately and only pays attention to the elements that are currently on the page. If you load some new elements through an AJAX call, you'll have to bind tipTip to everything in the new HTML. Whatever AJAX calls you're using should have a success callback, you can supply a callback that will re-do the .tipTip() call on the new HTML as you insert it into the page.

Upvotes: 2

illogikal
illogikal

Reputation: 158

Rails uses prototype by default currently so anything that uses jQuery, unless you use a gem requires this:

http://docs.jquery.com/Using_jQuery_with_Other_Libraries

I assume you're using the $( syntax... so just replace $( with jQuery( and call jQuery.noConflict(); at the beginning of the plugin.

Hope this helps.

Upvotes: 0

Related Questions