You’re not receiving notifications from this thread.
jQuery UJS and AJAX Discussion
While most of this was review for me, it was nice to see a tutorial that went so far in depth on the inner workings of Rails. The details you included would have been so handy to know in my early days of learning Rails.
Also, looks like you're using the Yosemite beta for OS X...what do you think?
One way to debug the JS response is in the Network tab of the web inspector. At least you can make sure the Javascipt is what you are expecting.
I guess it does trigger the "ajax:error" callback with the error, so we could listen for that. Looks like this gives a few decent examples: http://blog.bigbinary.com/2...
I'm looking to improve the js debugging in Rails 5 with this pull request:
Very cool. I really like this idea and certainly something that should be in Rails core if they continue supporting JS responses.
Thank you so much, Chris. So, if I want all my articles to appear via ajax, can I do what you describe above, and use the remote: true in link_to?
If you create a partial to render the list of articles, you can do that easily with this. If you have a div that contains all the articles:
You can create a link to load them:
<%= link_to "Load Articles", articles_path, remote: true %>
And then your articles.js.erb can insert them into the page:
That would render the _articles.html.erb partial, insert it into the JS response, and then when it gets executed, it will add it to the end of the #articles div.
Hi, I successfully added jquery_ujs functionality to ajaxify a controller action 'hide':
class ResearchersController < ApplicationController
@researcher = Researcher.find(params[:id])
my hide.js.erb file looks like this:
$("#researcher_<%= @researcher.id %>").text("<%= toggle_visibility(@researcher) %>");
This all works fine.
The problem however is that my integration test now fail with a 'missing template' error
How can I make the 'missing template' error in my tests go away?
Very well done. This concept never clicked for me as it has after watching this. I hope to subscribe soon!
Is there some sort of turbo links consideration here? Whenever I refresh the page it goes back to this date '2000-01-01 02:50:14 UTC' but the rails server output shows me that everything should have worked see picture. But if I check the record in the console I see the date above.
I have a feeling it's something obvious
My guess is that you might have a typo in your published.js.erb file causing it not to get executed. You can inspect the response in your browser and verify if you have any invalid code. Turbolinks or something could be caching the page to the old value but a refresh *should* display it with the latest value in your show action.
thanks for the quick reply, I hope to be a customer soon. Looks like the year is just refreshing to 2000-01-01 oddly and the actual time is behaving as it should. data-type is :time for published_at. Will need to do some more research.
Hmm, it definitely looks like it's working right. The date appears to have reset to a default value though. I'm going to guess the time column is similar to datetime which also stores the date (according to your logs, it looks right). If it doesn't though, then that could be why your dates keep resetting to 2000.
Thanks for the video. Never really got the hang of AJAX requests in Rails until now.
You done a video on how to load different views in your app using ajax. Similar to what you have this site where you load the whole content of the page using page. Abit like youtube.
Hi Chris. I used this method and pushed my git to heroku. However in the production mode, link_to wont route to PATCH but it routes to GET instead and JS.ERB file wont load. any fix ? (rails 4.1.4 ruby 2.0.0)
<%= link_to "Kabul", publish_proposal_path("accepted"), :method => :patch, remote: true %>
patch '/publish_proposal/:id' => 'charges#publish_proposal', as: :publish_proposal
@charges=Charge.where(:branduser_id => id).where(:status => status)
@charges=Charge.where(:instauser_id => id).where(:status => status)
data disable with only works with remote: true? because i used on "new book" (also using an sleep) but nothing happen.
I have a radio buttons group and before everything happens I need to validate if any option is checked, If so the request go on and Publish the book but if there's no option checked I need to send an alert to the user and stop the process.
How can I do that @excid3:disqus?