Search code examples
ruby-on-railsurlrailscastspushstatepjax

How turn off "replace url" in Pjax


I use Pjax with tutorial from http://railscasts.com/episodes/294-playing-with-pjax?view=comments I don't need change url and this coffee script code doesn't work:

.....

$("a#flag-comments").click ->

....

$.pjax

container: '[data-pjax-container-flag]',

replace: false,

url: '/flag_comments'

....

Any idea?


Solution

  • Edit: Please see clime's answer below - It appears my answer is no longer correct.


    Since the point of PJAX (pushState AJAX) is updating the url, I don't think there is a way to disable it. If updating the url isn't what your after you may just want to be using standard AJAX? (essentially use JQuery to perform an ajax get of a given path, then shove the contents in to a container of your choice)

    The "replace" option in the JQuery PJAX script simply toggles between using "replaceState" & "pushState" to update a pages url.

    Sorry i couldn't be of more help.