3 ms·
Thanks you for the links. I found a simple Rails pjax app and I am going through the code right now: https://github.com/edison/pjax-rails-sample https://github.
by mark_l_watson 15y ago
Thanks you for the links. I found a simple Rails pjax app and I am going through the code right now: https://github.com/edison/pjax-rails-sample https://github.com/edison/pjax-rails-sample
- tortilla 15y agoNice screencast too: http://railscasts.com/episodes/294-playing-with-pjax http://railscasts.com/episodes/294-playing-with-pjax
- irahul 15y agoLooking at the rails pjax_rails gem https://github.com/rails/pjax_rails https://github.com/rails/pjax_rails I see it automatically patches layout to return false when the request is pjax. https://github.com/rails/pjax_rails/blob/master/lib/pjax.rb#L5 https://github.com/rails/pjax_rails/blob/master/lib/pjax.rb#... layout ->(c) { pjax_request? ? false : 'application' } So in the sample app you pointed out: def show @post = Post.find(params[:id]) if pjax_request? render layout: false else respond_to :html end end is the same as: def show @post = Post.find(params[:id]) end Also, pjax-rails converts the following selection to pjax: https://github.com/rails/pjax_rails/blob/master/lib/assets/javascripts/pjax/enable_pjax.js.coffee https://github.com/rails/pjax_rails/blob/master/lib/assets/j... $('a:not([data-remote]):not([data-behavior]):not([data-skip-pjax])') I was a bit baffled by the example app since it didn't appear to be doing any pjaxy stuff, but rails being opinionated, I see all links are pjax(except the not classes show above), and layout is turned off for pjax requests.
- mark_l_watson 15y agoI put some debug printouts in his example notes controller and it seemed to be setting the no layout rendering option correctly, but as you say, the checks in the controller may be redundent. Anyway, I am planning on giving pjax a very good look: I find doing a lot of client side coding to be tedious and is something to be minimized.