vhochstein / active_scaffold

Rails 4 Version of activescaffold supporting jquery
MIT License
156 stars 34 forks source link

rails3: cannot make to work with ajax #35

Closed eugenekorpan closed 13 years ago

eugenekorpan commented 13 years ago

Hi, I have successfully installed the plugin and it works fine. But then I noticed that in the demo (http://demo.activescaffold.com/users) almost everything work with ajax (creating new item, sorting and so on) and in my project each action reloads the page. First I had javascript error in rails.js "document.on is not a function" and I have fixed that by wrapping the code with document.observe("dom:loaded", function() { // --- all functions with document.on }) and the error was gone but it didn't solve my problem with ajax.

So my environment: windows xp (ubuntu 10.04 has the same problem) rails 3.0.1 ruby 1.8.7 mozilla firefox, chrome

I have triple checked that all javascript are included, no javascirpt errors and some problems with blocking javascript, nothing like that. I have also noticed that in the demo in the titles all links have onclick function and in my project -no. But it has attributes "data-remote='true'" and that is why I think it should be with ajax.

Thanks

vhochstein commented 13 years ago

My guess is that there is something wrong with your rails.js file, which is the backbone for all ajax activities. Can you please try using the following rails.js file: https://github.com/vhochstein/prototype-ujs/raw/master/src/rails.js

and please make sure that protoype js library is loaded before rails.js in your application layout file.

In addition I would be interested if you received any error message while running active_scaffold_setup generator?

ghost commented 13 years ago

Confirm the same problem with jquery.

Rails 3.0.3 ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] GNU Icecat 3.6.12

Setup was made by hand, having active_scaffold_setup generator as example (the setup (as all other ruby HTTP connections) itself just doesn't work with our fascist corporative firewall+proxy: it cann't respect http_proxy environment variable): /usr/lib/ruby/1.9.1/open-uri.rb:346:in 'open_http': 407 Proxy Authentication Required (OpenURI::HTTPError)

vhochstein commented 13 years ago

@korobkov: Well, I would say we ve got two ways to go.

  1. generate a small minimal example application using sqlite and send it to me v.hochstein@highstone.de
  2. We will try to find the reason remotely. First step would be to paste your application layout file?
ghost commented 13 years ago

Volker, I'm very sorry to spend your time just because of my mistake: when I tried to install AS with jquery I forgot to install https://github.com/rails/jquery-ujs (:

With this installed AJAX behavior is almost good (except search and update subforms, don't know for what reason...) May be I should do something else to have it working completely? Could you mention it in you blog?

Thank your for very fast help offer! :) Andrey

jquery 1.4.3 and 1.4.4 jquery-ui 1.8.6

vhochstein commented 13 years ago

Two quite obvious issues: Firstly, I ve tested activescaffold only with jquery 1.4.1 and 1.4.2. 1.4.3 had severe issues and it didnt make sense to use it and unfortunelty I had no time so far to check 1.4.4

Secondly, you need a special jquery rails.js file if you are using jquery with activescaffold. You may find it here: https://github.com/vhochstein/jquery-ujs/raw/master/src/rails.js

Just replace it with the existing one.

Bottomline: Try Jquery 1.4.1 and replace rails.js.

Hope that helps

ghost commented 13 years ago

Thanks, Volker. That your advice solves the problems even without any debugging. :) Now all AJAX works ideally.

vhochstein commented 13 years ago

You are welcome and I love to close issues. :-)