Topic: Ajax and JQuery

I have used Ajax link and live validation in index.rhtml
Ajax link requires JavaScript "prototype" and live validation requires "jquery".
i got "element.dispatchEvent is not a function" on the firebug console when i used "prototype" and "jquery" in same page index.rhtml
after i removed javascript "prototype" library, i got "Ajax is not defined" on the firebug console when i clicking ajax link.
how can i use both ajax and jquery in the same page?
Can anybody give me a solution for this?

For example:

<%=javascript_include_tag "prototype"%>
<%=javascript_include_tag "jquery"%>
<%= javascript_include_tag 'livevalidation/jquery.validate' %>
<%= javascript_include_tag 'livevalidation/jquery.validation.functions' %>
<%= stylesheet_link_tag 'livevalidation/jquery.validate' %>
<%= stylesheet_link_tag 'livevalidation/style' %>
           

<%=link_to_remote "new user",:url=>{:action=>:a},:update=>"div"%>
<div id="div"></div>
<% form_for(@user) do |f| %>
    <p>
        <%= f.label :name %><br />
        <%= f.text_field :name %><br />
    </p>
    <p>
        <%= f.submit "Register"%>
    </p>
<% end %>

Last edited by willm (2010-06-02 08:04:00)

Re: Ajax and JQuery

In order to use jquery and rails,  you have to replace the prototype helpers with jquery helpers, essentially.

Get the JRails plugin,

Works great,  easy to install, etc.

There is also a way (I believe), to set some kind of compatibility mode in jQuery so the two libraries (JQuery & Prototype) don't collide in the namespace,  I think that's also supposed to work, but I've never tried.  JRails seemed the cleanest way to me so that's what I did.

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Ajax and JQuery

friend my problem is that is javascript is require to be learn before  go for ajax

Re: Ajax and JQuery

I see this :

<%=javascript_include_tag "prototype"%>
<%=javascript_include_tag "jquery"%>

Two plugin fight because some methods.In project or use protype or use jquery.

Last edited by d.danailov (2010-07-09 17:45:22)