After some research as to how I should replace Prototype with jQuery I've ended up with this jquery-rails:
gem 'jquery-rails', '>= 1.0.3'
rails g jquery:install
rails s
I've included the :defaults files (which jquery-rails should have replacements for) but I'm getting errors when implementing an AJAX login script. Creating sessions and logging the user in goes well, but the code generates errors:
TypeError: Object function Element() { [native code] } has no method 'update' Element.update("sidebar", ":partial => 'layouts/user'");
Controller:
sign_in user
respond_to do |format|
format.js {
render :update do |page|
page.replace_html 'sidebar' , ":partial => 'layouts/user'"
end
}
Form:
<nav id="sidebar">
<%= form_for :session, :url => sessions_path, :remote => true do |f| %>
<div>
<%= f.label :email %><br />
<%= f.text_field :email, :class => "span-4" %>
</div>
<div>
<%= f.label :password %><br />
<%= f.password_field :password, :class => "span-4" %>
</div>
<div>
<%= f.submit "Sign in" %>
</div>
<% end %>
</nav>
If I'm not mistaken jquery-rails is supposed to be a drop-in replacement for Prototype. So I'm guessing I'm doing something wrong?
Edit:
Added the sidebar nav